Xii Record Note 2025-26
Xii Record Note 2025-26
Program:
def Fibonacci(n):
firsterm = -1
secondterm = 1
for i in range(n):
thirdterm = firsterm + secondterm
print(thirdterm,end = " ")
firsterm = secondterm
secondterm = thirdterm
print("Fibonacci Series")
n = int(input("Enter the number of terms you want to print: ")) Fibonacci(n)
1
[Link]: 02 Palindrome
Date: 25-04-2025
Program:
def Palindrome(myLength):
for i in (0,myLength//2):
if myString[i] != myString[myLength-i-1]:
print("The given string",myString," is not a Palindrome")
break
else:
continue
else:
print("The given string",myString," is a Palindrome")
print("Palindrome Check")
myString = input("Enter a string: ")
myLength = len(myString)
Palindrome(myLength)
Palindrome Check
Enter a string: Madam
The given string Madam is not a Palindrome
Palindrome Check
Enter a string: MalayalaM
The given string MalayalaM is a Palindrome
2
[Link]: 03 Printing the largest and smallest country name in the list
Date: 06-06-2025
Aim: To create a list with different country names and print the largest and the
smallest country (by counting the number of characters) using function.
Program:
def MaxMin(n):
Country = []
for i in range(n):
cname = input('Enter the country name: ')
[Link](cname)
[Link](key=len)
print('Country with the smallest length = ',Country[0])
print('Country with the largest length = ',Country[-1])
n = int(input('Enter the no. of country: '))
MaxMin(n)
3
[Link]: 04 Menu driven program to calculate area of different shapes
Date: 13-06-2025
Program:
4
Sample Input and Output:
Menu Driven Program to Compute the Area of different shapes
5
3. To compute area of a triangle
4. Exit
6
[Link]: 05 Search and display using dictionary
Date: 26-06-2025
Aim: To create a dictionary to store roll number and name of 5 students, for a given
roll number display the corresponding name else display appropriate error message.
Program:
myDict = {}
def InputDictionary():
for i in range(5):
rno = int(input('Enter the rollno: '))
name = input('Enter the name: ')
myDict[rno] = name
print(myDict)
def Search(n):
found = 0
for i in myDict:
if i == n:
found = 1
print('The element is found')
print(i,' ',myDict[i])
break
if found == 0:
print(n,' is not found in the dictionary')
InputDictionary()
n = int(input('Enter the key to be searched: '))
Search(n)
7
Sample Input and Output:
8
[Link]: 06 Division Calculator (Exception Handling)
Date: 04-07-2025
Program:
def divide_numbers():
try:
print(f"Result: {result}")
except ZeroDivisionError:
except ValueError:
finally:
print("Execution completed.")
divide_numbers()
9
Sample Input and Output:
10
[Link]: 07 Read a text file line by line and print # after each word
Date: 10-07-2025
Aim: To read a text file, line by line and display each word separated by ‘#’
Program:
def Line2WordaddHash():
with open('[Link]') as F:
Lines = [Link]()
myList = []
for i in Lines:
myList = [Link]()
for j in myList:
print(j,"#",end= " ")
Line2WordaddHash()
[Link]
11
[Link]: 08 Printing all the lines starting with ‘T’
Date: 17-07-2025
Aim: To read a text file and print all the lines that are starting with ‘T’ on the screen
Program:
def PrintSpecificLines():
with open('[Link]') as F:
Reader = [Link]()
for line in Reader:
if line[0] == 'T':
print(line)
PrintSpecificLines()
[Link]
12
[Link]: 09 Counting the number of occurrences
Date: 25-07-2025 of ‘is’ and ‘and ‘ in a text file
Aim: To read a text file and count the number of occurrences of ‘is’ and ‘and’ in that
file.
Program:
def Countisand():
with open('[Link]','r') as rfile:
Reader = [Link]()
print(Reader)
count = 0
for line in Reader:
words = [Link]()
for i in words:
if i == 'is' or i == 'and':
count+=1
print('The total no. of words with is / and = ',count)
Countisand()
['This is my sample text file program to count the number of occurrences of is and and
present in this text file.']
The total no. of words with is / and = 4
13
[Link]: 10 Counting vowels, consonants, digits, And special characters,
Date: 05-08-2025 lower case & upper case letters present in a text file.
Aim: To count the number of vowels, consonants, digits, special characters, lower
case & upper case letters present in a text file and display the same.
Program:
def TextFileCounting():
ucase = 0
lcase = 0
vowels = 0
consonants = 0
digits = 0
special = 0
with open('[Link]') as rtextfile:
Read = [Link]()
for ch in Read:
if [Link]():
if ch in ['a','e','i','o','u','A','E','I','O','U']:
vowels+=1
else:
consonants+=1
if [Link]():
ucase+=1
if [Link]():
lcase+=1
elif [Link]():
digits+=1
else:
special+=1
print('No of uppercase alphabets = ',ucase)
14
print('No of lowercase alphabets = ',lcase)
print('No of digits = ',digits)
print('No of vowels = ',vowels)
print('No of consonants = ',consonants)
print('No of special characters = ',special)
TextFileCounting()
Aim: To read a text file and create a new file after adding “ing” to all words ending
with ‘s’ and ‘d’
Program:
def Adding_ing():
with open('[Link]','r') as rfile:
with open('Mywordfilewith_ing.txt','w') as wfile:
Reader = [Link]()
print(Reader)
Adding_ing()
['This is my sample text file program to count the number of occurrences of is and and
present in this text file.']
['Thisingisingmysampletextfileprogramtocounthenumberofoccurrancesingofisingandingan
din gpresentinthisingtextfile.']
Program:
import csv stu = []
def write_csv_data():
with open('[Link]','a',newline='') as F:
Write = [Link](F)
ch = 'y'
while ch == 'y':
name = input('Enter the student name:')
totalmarks = int(input('Total marks:'))
stu = [name,totalmarks]
[Link](stu)
ch = input('Do you want to continue y/n: ')
def read_csv_data():
with open('[Link]','r') as F:
Reader = [Link](F)
for Data in Reader:
print(Data[0],int(Data[1]),int(Data[1])/5)
write_csv_data()
read_csv_data()
17
Sample Input and Output:
18
[Link]: 13 Copying the contents of one csv file to another
Date: 29-08-2025 using different delimiter
Aim: To copy the contents of a csv file into another file using different delimiter
Program:
import csv
def copy_csv_data():
with open('[Link]') as F1:
with open('[Link]','w',newline='') as F2:
Read = [Link](F1)
Write = [Link](F2,delimiter= '#')
for line in Read:
[Link](line)
def display_copied_data():
with open('[Link]') as F:
Reader = [Link](F)
for Data in Reader:
print(Data)
copy_csv_data()
display_copied_data()
['100#Hamam#28']
['101#Cinthol#29']
['102#Dove#45']
19
[Link]: 14 Binary Files - Search and display using binary file
Date: 04-09-2025
Aim: To create a binary file to store member no and member name. Given a member
no, display its associated name else display appropriate error message.
Program:
def Store_binary_info():
with open('[Link]','ab') as wbfile:
while True:
Mno = int(input('Enter the member no: '))
name = input('Enter the name: ')
Member['MemberNo'] = Mno
Member['Name'] = name
[Link](Member,wbfile)
ch = input('Do you want to continue y/n :')
if ch == 'n':
print('Binary File writing is over')
break
def Search_display_binary_info():
with open('[Link]','rb') as rbfile:
mno = int(input('Enter the member no to be searched:'))
try:
while True:
Member = [Link](rbfile)
if Member['MemberNo'] == mno:
print(Member)
break
except EOFError:
print('MemberNo not found')
20
Store_binary_info()
Search_display_binary_info()
Search_display_binary_info()
21
[Link]: 15 Menu driven program to write/read/update
Date: 11-09-2025 and append data on to binary file
Aim: To create a menu driven program to write, read, update and append data on to a
binary file.
Program:
import pickle
Member = {}
def Writing_Binary():
with open('[Link]','wb') as wbfile:
while True:
Mno = int(input('Enter the member no: '))
name = input('Enter the name: ')
Member['MemberNo'] = Mno
Member['Name'] = name
[Link](Member,wbfile)
ch = input('Do you want to continue y/n :')
if ch == 'n':
print('Binary File writing is over')
break
def Read_Display_Binary():
with open('[Link]','rb') as rbfile:
try:
while True:
Member = [Link](rbfile)
print(Member)
except EOFError:
print('Finished reading binary file')
def Update_Binary():
found = False
22
with open('[Link]','rb+') as rbfile:
try:
while True:
rpos = [Link]()
Member = [Link](rbfile)
if Member['Name'] == 'Sundar':
Member['Name'] = 'Sundari'
[Link](rpos)
[Link](Member,rbfile)
print(Member)
found = True
break
except EOFError:
if found == False:
print('Data not updated in the file')
else:
print('Data updated successfully')
def Append_Binary():
with open('[Link]','ab') as wbfile:
while True:
Mno = int(input('Enter the member no: '))
name = input('Enter the name: ')
Member['MemberNo'] = Mno
Member['Name'] = name
[Link](Member,wbfile)
ch = input('Do you want to continue y/n :')
if ch == 'n':
print('Binary File writing is over')
break
while True:
print(' ')
print('Menu Driven Programming')
print(' ')
23
print('1. To create and store binary data')
print('2. To read the binary data')
print('3. To update the binary data')
print('4. To append data to the binary file')
print('5. To exit')
ch = int(input('Enter your choice: '))
if ch == 1:
Writing_Binary()
elif ch == 2:
Read_Display_Binary()
elif ch == 3:
Update_Binary()
elif ch == 4:
Append_Binary()
elif ch == 5:
break
24
Menu Driven Programming
25
Menu Driven Programming
26
[Link]: 16 Stack operation
Date: 25-09-2025
Program:
stack=[ ]
def view( ):
for x in range(len(stack)):
print(stack[x])
def push( ):
[Link](item)
def pop( ):
if(stack= =[ ]):
print("Stack is empty")
else:
item=[Link](-1)
print("Deleted element:",item)
def peek( ):
item=stack[-1]
print("Peeked element:",item)
print("Stack operation")
print("************")
print("[Link]")
print("[Link]")
print("[Link]")
27
if choice= =1:
view( )
push( )
elif choice==3:
pop( )
peek( )
else:
print("Wrong choice")
Output:
Stack operation
************
1. view
2. push
3. pop
4. peek
56
78
90
28
Enter your choice4
Peeked element: 90
Deleted element: 90
5678
Peeked element: 78
Wrong choice
Result:
29
[Link]: 17 Stationary and consumer
Date: 30-09-2025
Aim: To create two tables for stationary and consumer and execute the given commands
using SQL.
TABLE: STATIONARY
TABLE: CONSUMER
iii) To display the ConsumerName , Address from table Consumer and Company and
Price from table Stationery with their corresponding matching S_ID
30
Output:
iii) select consumername, address, company, price from stationery, consumer where
stationery.s_id=consumer.s_id;
31
GP02 Gel pen ABC 17
Company
ABC
XYZ
CAM
32
[Link]: 18 Item and traders
Date: 03-10-2025
Aim: To create two tables for item and traders and execute the given commands using
SQL.
TABLE: ITEM
TABLE:TRADERS
i) To display the details of all the items in ascending order of item names (i.e
IName)
ii) To display item name and price of all those items, whose price is in the range
of 10000 and 22000 (both values inclusive)
iii) To display the number of items, which are traded by each trader. The expected
output of this query should be
T01 2
T02 2
T03 1
iv) To display the Price, item name (i.e IName) and quantity (i.e Qty) of those
items which have quantity more than 150.
v) To display the names of those traders, who are either from DELHI or from
MUMBAI?
33
Output:
ii) select IName , Price from ITEM where Price between 10000 and 22000;
IName Price
Tcode Count(*)
T01 2
T02 2
T03 1
TName
ELECTRONICS SALES
34
[Link]: 19 Doctor and salary
Date: 09-10-2025
Aim: To create two tables for doctor and salary and execute the given commands using
SQL.
TABLE:DOCTOR
TABLE: SALARY
35
i) Display NAME of all doctors who are in “MEDICINE” having more than 10 years
experience from table DOCTOR
ii) Display the average salary of all doctors working in “ENT” department using the
tables DOCTOR and SALARY. (Salary=BASIC+ALLOWANCE)
iv) Display [Link] , NAME from the table DOCTOR and BASIC , ALLOWANCE from
the table SALARY with their corresponding matching ID.
Output:
Avg salary
13000.00
min(ALLOWANCE)
1700
36
iv) select [Link], NAME, BASIC ,ALLOWANCE from DOCTOR,SALARY where
[Link]=[Link];
DEPT
ENT
ORTHOPEDIC
CARDIOLOGY
SKIN
MEDICINE
37
[Link]: 20 Integrate python with sql - fetching records from table
Date: 13-10-2025
Aim: To integrate SQL with Python by importing the MySQL module and extracting data
from result set
Program:
if mycon.is_connected( ) == False:
cursor=[Link]( )
data=[Link](3)
count=[Link]
print(row)
[Link]( )
Output:
Aim: To integrate SQL with Python by importing the MySQL module and extracting data
from result set
Program:
if mycon.is_connected( ) == False:
cursor=[Link]( )
data=[Link]( )
count=[Link]
data=[Link]( )
count=[Link]
data=[Link](3)
count=[Link]
39
Output:
40
[Link]: 22 Integrate sql with python - searching a record from table
Date: 29-10-2025
Aim: Integrate SQL with Python by importing the MySQL module to search an employee
using eno if it is present in table display the record
Program:
import [Link] as mc
mycon=[Link](host='localhost',user='root',password='root1',database='db12')
if mycon.is_connected( ):
print("Py->Sql connected")
eno=int(input("Enter num:"))
mcursor=[Link]( )
allrow=[Link]( )
if row[0]==eno:
print(row)
[Link]( )
Output:
Result:
41
[Link]: 23 Integrate sql with python - deleting a record from table
Date: 04-11-2025
Aim: To integrate SQL with Python by importing the MySQL module to search a student
using rollno and delete the record.
Program:
import [Link] as mc
mycon=[Link](host='localhost',user='root',password='root1',database='db12')
if mycon.is_connected():
print("Py->Sql connected")
eno=int(input("Enter num:"))
mcursor=[Link]()
allrow=[Link]()
if row[0]==eno:
[Link]()
print([Link]())
[Link]()
42
Output:
(101,’Anu’,23,’Salem’)
(103,’Cinu’,43,’Namakkal’)
Result:
43
[Link]: 24 Company and customer
Date: 10-11-2025
Aim: To create two tables for company and customer and execute the given
commands using SQL.
TABLE: COMPANY
TABLE: CUSTOMER
1. To display those company name which are having price less than 30000.
2. To display the name of the companies in reverse alphabetical order.
3. To increase the price by 1000 for those customer whose name starts
with ‘S’
4. To add one more column totalprice with decimal (10,2) to the table
customer
44
Output :
1. Select name from company where [Link]=customer. cid and price < 30000
NAME
NEHA SONI
2. Select name from company order by name desc;
NAME
SONY
ONIDA
NOKIA
DELL
BLACKBERRY
3. update customer set price = price + 1000 where name like ‘s%’; select * from customer;
45
4. alter table customer add totalprice decimal(10,2); Select * from customer;
46
[Link]: 25 Sql: Teacher (relation)
Date: 18-11-2025
Aim: To create table for teacher and execute the given commands using SQL.
TABLE : TEACHER
3. To list names of all teachers with their date of joining in ascending order.
47
Output:
Name
Shriya
Name Dateofjoin
Santhosh 12/12/96
Jishnu 10/01/97
Shakthi 25/02/97
Shiva 27/02/97
Shriya 31/07/97
Ragu 05/09/97
Sharmila 24/03/98
Shanmathi 01/07/99
48
4. select count(*) from teacher where Age>35;
count(*)
Department count(*)
Computer 2
History 3
Maths 3
49