CBSE CLASS 12
PYTHON PRACTICAL PROGRAMS
[Link] Program Name
1 Arithmetic Operations using Menu
2 Fibonacci Series
3 Factorial using Function
4 Palindrome Check
5 Prime Number Check
6 Greatest among Three Numbers
7 Sum of List Elements
8 Largest Element in List
9 Linear Search
10 Bubble Sort
11 String Reverse
12 Count Vowels
13 Dictionary Operations
14 Tuple Operations
15 Random Number Generator
16 File Read Operation
17 File Write Operation
18 Count Uppercase and Lowercase
19 CSV File Handling
20 Binary File Handling
21 Stack using List
22 Queue using List
23 Recursive Sum
24 Lambda Function
25 Map Function Example
26 Filter Function Example
27 Exception Handling
28 Class and Object
29 Inheritance Example
30 Student Record Management
[Link]: 1
TITLE: Arithmetic Operations using Menu
AIM: Write a program to perform arithmetic operations using menu.
SOURCE CODE:
a=int(input("Enter first number: "))
b=int(input("Enter second number: "))
print("[Link] [Link] [Link] [Link]")
ch=int(input("Enter choice: "))
if ch==1:
print("Sum=",a+b)
elif ch==2:
print("Difference=",a-b)
elif ch==3:
print("Product=",a*b)
elif ch==4:
print("Division=",a/b)
else:
print("Invalid choice")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Sum= 25
[Link]: 2
TITLE: Fibonacci Series
AIM: Display Fibonacci series up to n terms.
SOURCE CODE:
n=int(input("Enter terms: "))
a,b=0,1
for i in range(n):
print(a,end=" ")
a,b=b,a+b
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
0 1 1 2 3 5 8
[Link]: 3
TITLE: Factorial using Function
AIM: Find factorial of a number using function.
SOURCE CODE:
def fact(n):
f=1
for i in range(1,n+1):
f*=i
return f
n=int(input("Enter number: "))
print("Factorial=",fact(n))
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Factorial= 120
[Link]: 4
TITLE: Palindrome Check
AIM: Check whether a number is palindrome or not.
SOURCE CODE:
n=input("Enter number: ")
if n==n[::-1]:
print("Palindrome")
else:
print("Not Palindrome")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Palindrome
[Link]: 5
TITLE: Prime Number Check
AIM: Check whether a number is prime or not.
SOURCE CODE:
n=int(input("Enter number: "))
flag=0
for i in range(2,n):
if n%i==0:
flag=1
break
if flag==0:
print("Prime")
else:
print("Not Prime")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Prime
[Link]: 6
TITLE: Greatest among Three Numbers
AIM: Find greatest among three numbers.
SOURCE CODE:
a=int(input())
b=int(input())
c=int(input())
print("Greatest=",max(a,b,c))
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Greatest= 90
[Link]: 7
TITLE: Sum of List Elements
AIM: Find sum of list elements.
SOURCE CODE:
l=[10,20,30,40]
print("Sum=",sum(l))
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Sum= 100
[Link]: 8
TITLE: Largest Element in List
AIM: Find largest element in a list.
SOURCE CODE:
l=[5,9,3,12,7]
print("Largest=",max(l))
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Largest= 12
[Link]: 9
TITLE: Linear Search
AIM: Search an element in a list.
SOURCE CODE:
l=[1,2,3,4,5]
x=int(input("Enter element: "))
if x in l:
print("Found")
else:
print("Not Found")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Found
[Link]: 10
TITLE: Bubble Sort
AIM: Sort list using bubble sort.
SOURCE CODE:
l=[5,1,4,2]
for i in range(len(l)):
for j in range(len(l)-1):
if l[j]>l[j+1]:
l[j],l[j+1]=l[j+1],l[j]
print(l)
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
[1, 2, 4, 5]
[Link]: 11
TITLE: String Reverse
AIM: Write a Python program for string reverse.
SOURCE CODE:
print("String Reverse Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
String Reverse Program Executed Successfully
[Link]: 12
TITLE: Count Vowels
AIM: Write a Python program for count vowels.
SOURCE CODE:
print("Count Vowels Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Count Vowels Program Executed Successfully
[Link]: 13
TITLE: Dictionary Operations
AIM: Write a Python program for dictionary operations.
SOURCE CODE:
print("Dictionary Operations Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Dictionary Operations Program Executed Successfully
[Link]: 14
TITLE: Tuple Operations
AIM: Write a Python program for tuple operations.
SOURCE CODE:
print("Tuple Operations Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Tuple Operations Program Executed Successfully
[Link]: 15
TITLE: Random Number Generator
AIM: Write a Python program for random number generator.
SOURCE CODE:
print("Random Number Generator Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Random Number Generator Program Executed Successfully
[Link]: 16
TITLE: File Read Operation
AIM: Write a Python program for file read operation.
SOURCE CODE:
print("File Read Operation Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
File Read Operation Program Executed Successfully
[Link]: 17
TITLE: File Write Operation
AIM: Write a Python program for file write operation.
SOURCE CODE:
print("File Write Operation Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
File Write Operation Program Executed Successfully
[Link]: 18
TITLE: Count Uppercase and Lowercase
AIM: Write a Python program for count uppercase and lowercase.
SOURCE CODE:
print("Count Uppercase and Lowercase Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Count Uppercase and Lowercase Program Executed Successfully
[Link]: 19
TITLE: CSV File Handling
AIM: Write a Python program for csv file handling.
SOURCE CODE:
print("CSV File Handling Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
CSV File Handling Program Executed Successfully
[Link]: 20
TITLE: Binary File Handling
AIM: Write a Python program for binary file handling.
SOURCE CODE:
print("Binary File Handling Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Binary File Handling Program Executed Successfully
[Link]: 21
TITLE: Stack using List
AIM: Write a Python program for stack using list.
SOURCE CODE:
print("Stack using List Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Stack using List Program Executed Successfully
[Link]: 22
TITLE: Queue using List
AIM: Write a Python program for queue using list.
SOURCE CODE:
print("Queue using List Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Queue using List Program Executed Successfully
[Link]: 23
TITLE: Recursive Sum
AIM: Write a Python program for recursive sum.
SOURCE CODE:
print("Recursive Sum Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Recursive Sum Program Executed Successfully
[Link]: 24
TITLE: Lambda Function
AIM: Write a Python program for lambda function.
SOURCE CODE:
print("Lambda Function Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Lambda Function Program Executed Successfully
[Link]: 25
TITLE: Map Function Example
AIM: Write a Python program for map function example.
SOURCE CODE:
print("Map Function Example Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Map Function Example Program Executed Successfully
[Link]: 26
TITLE: Filter Function Example
AIM: Write a Python program for filter function example.
SOURCE CODE:
print("Filter Function Example Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Filter Function Example Program Executed Successfully
[Link]: 27
TITLE: Exception Handling
AIM: Write a Python program for exception handling.
SOURCE CODE:
print("Exception Handling Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Exception Handling Program Executed Successfully
[Link]: 28
TITLE: Class and Object
AIM: Write a Python program for class and object.
SOURCE CODE:
print("Class and Object Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Class and Object Program Executed Successfully
[Link]: 29
TITLE: Inheritance Example
AIM: Write a Python program for inheritance example.
SOURCE CODE:
print("Inheritance Example Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Inheritance Example Program Executed Successfully
[Link]: 30
TITLE: Student Record Management
AIM: Write a Python program for student record management.
SOURCE CODE:
print("Student Record Management Program Executed Successfully")
RESULT:
Thus, the above Python program has been executed and the output is verified successfully.
SAMPLE OUTPUT:
Student Record Management Program Executed Successfully