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

Class XII Python SQL Practical With Outputs

The document contains practical programs for Class XII Computer Science, including a recursive factorial function, a Fibonacci series generator, and a palindrome checker. Each program is accompanied by sample input and output. Additionally, there is an SQL query to display all records from a student database.

Uploaded by

TANUJ pattanayak
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)
3 views2 pages

Class XII Python SQL Practical With Outputs

The document contains practical programs for Class XII Computer Science, including a recursive factorial function, a Fibonacci series generator, and a palindrome checker. Each program is accompanied by sample input and output. Additionally, there is an SQL query to display all records from a student database.

Uploaded by

TANUJ pattanayak
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 XII Computer Science Practical Programs

(With Outputs)

1. Factorial using Recursion


def factorial(n):
if n == 0 or n == 1:
return 1
return n * factorial(n-1)

num = int(input("Enter number: "))


print("Factorial:", factorial(num))

Output:
Enter number: 5
Factorial: 120

2. Fibonacci Series
def fib(n):
if n <= 1:
return n
return fib(n-1) + fib(n-2)

n = int(input("Enter terms: "))


for i in range(n):
print(fib(i), end=" ")

Output:
Enter terms: 6
0 1 1 2 3 5

3. Palindrome Check
def is_palindrome(s):
if len(s) <= 1:
return True
if s[0] != s[-1]:
return False
return is_palindrome(s[1:-1])

s = input("Enter string: ")


print("Palindrome" if is_palindrome(s) else "Not Palindrome")

Output:
Enter string: madam
Palindrome
SQL: Display All Records
SELECT * FROM student;

Output:
roll | name | class | marks
1 | Aman | 12 | 85
2 | Riya | 12 | 90
3 | Rahul | 12 | 78

You might also like