0% found this document useful (0 votes)
7 views2 pages

Class 12 Python & SQL Practical Guide

The document contains a practical file for Class 12 Computer Science, featuring Python functions for various tasks such as checking even/odd, calculating factorials, and finding prime numbers. It also includes SQL commands for creating a STUDENT table, inserting records, and querying data. Each section provides clear examples and code snippets for students to follow.

Uploaded by

kumarritesh3938
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Class 12 Python & SQL Practical Guide

The document contains a practical file for Class 12 Computer Science, featuring Python functions for various tasks such as checking even/odd, calculating factorials, and finding prime numbers. It also includes SQL commands for creating a STUDENT table, inserting records, and querying data. Each section provides clear examples and code snippets for students to follow.

Uploaded by

kumarritesh3938
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Class 12 Computer Science Practical File

SECTION A: PYTHON FUNCTION QUESTIONS WITH ANSWERS

1. Write a function to check even or odd.


def even_odd(n):
if n % 2 == 0:
return "Even"
else:
return "Odd"

2. Write a function to find factorial.


def factorial(n):
f = 1
for i in range(1, n+1):
f *= i
return f

3. Write a function to find sum of digits.


def sum_digits(n):
s = 0
while n > 0:
s += n % 10
n //= 10
return s

4. Write a function to check prime number.


def is_prime(n):
if n <= 1:
return False
for i in range(2, n):
if n % i == 0:
return False
return True

5. Write a function to reverse a string.


def reverse_string(s):
return s[::-1]

6. Write a function to check palindrome.


def is_palindrome(s):
return s == s[::-1]

7. Write a function to count vowels.


def count_vowels(s):
c = 0
for i in [Link]():
if i in 'aeiou':
c += 1
return c

8. Write a function to find maximum in a list.


def max_list(lst):
return max(lst)

9. Write a function to find minimum in a list.


def min_list(lst):
return min(lst)

10. Write a function to find Fibonacci series.


def fibonacci(n):
a, b = 0, 1
for i in range(n):
print(a, end=' ')
a, b = b, a+b

SECTION B: SQL QUESTIONS WITH ANSWERS

1. Create STUDENT table.


CREATE TABLE STUDENT(
RollNo INT,
Name VARCHAR(30),
Class VARCHAR(10),
Marks INT
);

2. Insert records.
INSERT INTO STUDENT VALUES
(1,'Aman','12A',78),
(2,'Riya','12A',85),
(3,'Karan','12B',67);

3. Display all records.


SELECT * FROM STUDENT;

4. Students scoring more than 75.


SELECT Name FROM STUDENT WHERE Marks > 75;

5. Update marks.
UPDATE STUDENT SET Marks = 90 WHERE RollNo = 1;

You might also like