PM SHRI
Kendriya
Vidyalaya
SESSION: 2023-24
NAME: JIYA. S
CLASS: XII
SECTION: ‘B’
ROLL NO.: 12206
SUBJECT: COMPUTER SCIENCE
TEACHER’S SIGNATURE PRINCIPAL’S SIGNATURE
REVISION TOUR
Page 1 of 25
1. Write a program to check whether the given number is
a prime number or not.
OUTPUT:
2. Write a program to generate random numbers between
1 to 6 and check whether a user won a lottery or not.
OUTPUT:
Page 2 of 25
3. Write a menu driven program to perform following in
dictionary (roll no, name) add, update, display, display
all.
OUTPUT:
Page 3 of 25
USER DEFINED FUNCTIONS
4. Write a program to calculate the factorial of an integer
using function.
OUTPUT:
5. Write a program to find sum of all elements of a list
passed as parameter using function.
OUTPUT:
Page 4 of 25
6. Write a program to print Fibonacci series using
function.
OUTPUT:
7. Write a program to find and return GCD and LCM of
two numbers using function.
OUTPUT:
Page 5 of 25
8. Write a function to test if a string passed is a
palindrome or not.
OUTPUT:
9. Write a python program using function to pass list to a
function and double the odd values and half the even values
of a list and display list elements after changing.
OUTPUT:
Page 6 of 25
10. Write a menu driven program using functions that takes
a tuple as a parameter and return maximum, minimum and
sum of the elements.
OUTPUT:
Page 7 of 25
TEXT FILE
11. Write a program to read a text file and display its
contents.
OUTPUT:
12. Write a program to read a text file and display the
number of vowels/ consonants/ uppercase/ lowercase/
characters/ digits present in the file.
Page 8 of 25
OUTPUT:
13. Write a program to count the number of “is” word on a
text file.
OUTPUT:
14. Write a program to count the number of lines starting
with ‘A’.
OUTPUT:
Page 9 of 25
15. Write a program to read a text file line by line and
display each word separated by “#”.
OUTPUT:
16. Write a program to write those lines which have the
character ‘p’ from one text file to another text file.
OUTPUT:
Page 10 of 25
BINARY FILE
17. Write a program to create a binary file
Student.dat [Roll no, Name, Marks] and write a menu
driven program to do the following:
• Insert record
• Search record (get roll no)
• Update record
• Display all
• Exit
Page 11 of 25
OUTPUT:
18. Write a program to read all the content of
“student.csv” and display records of only those
students who scored more than 80 marks. Records
stored in students is in format: Rollno, Name, Marks.
OUTPUT:
Page 12 of 25
19. Create a CSV file(Emp.csv, empno, ename,
salary)and write a menu driven Program to do the
following:
• Add a record
• Search record(get empno)
• Display all
• Exit
Page 13 of 25
OUTPUT:
Page 14 of 25
20. Write a program to show the detail of the student who
scored the highest marks. Data stored in “Data.csv” is given
below:
Roll no, Name, Marks.
1, Aman, 35 2, Kanak, 1 3, Anuj, 33 4, suman, 25
OUTPUT:
CONNECTIVITY PYTHON
Page 15 of 25
Practical 1
Aim to connect to MySQL server
To create a database Student
To create a table Student
To add 6 rows
To fetch and display the records
OUTPUT:
Practical 2
Page 16 of 25
Aim
To Connect to database student
To create a table result
To add six rows
To increase marks in Math by 5 for Sudha
To fetch and display the records
OUTPUT:
Practical 3
Page 17 of 25
Aim
To Connect to database student
To create a table result
To add six rows
To delete the rows with math mark greater or
equal to 90
To fetch and display the records
OUTPUT:
Practical 4
Page 18 of 25
Aim
To connect to database student
To create a Table staff
To add 6 rows
To fetch and display the records of all
OUTPUT:
MYSQL
Page 19 of 25
1. Create database name ‘kv2’.
2. Open the database ‘kv2’.
3. Create the following table: Student
4. Add the following rows in the table student.
5. Display all the tables.
6. Display the details of all students.
7. Give the structure of the table student.
Page 20 of 25
8. Display the name and marks of all students.
9. Display the details of all students whose name contains second
letter as ‘a’.
10. Display the details of all students in descending order of their
names.
Page 21 of 25
11. Display the name of those students whose city is not
found.
12. Display the name and city of those students who
belongs to Chennai or Delhi.
13. Display the name of those students whose age is 17
and belongs to Delhi.
14. Display the details of all students whose marks is in the
range of 400 to 450.
15. Display the details of all students whose marks is not in
the range of 400 to 450.
Page 22 of 25
16. Display the name of those students who belongs to
Delhi, Chennai or Kolkata.
17. Display the details of all students whose name contains
second last letter as ‘a’.
18. Display the names of all students whose name contains
5 letters.
19. Display the names of all students whose name contains
last letter as ‘a’.
Page 23 of 25
20. Display the names of different cities.
21. Display the details of all students in ascending order of
city and then in descending order of names.
22. Change the mark of Ramya as 390.
23. Give extra 10 marks to all students.
24. Remove the details of those students who resides in
‘Chennai’.
25. Add a column named email id of type varchar and size
50.
26. Increase the size of city column as 20.
Page 24 of 25
27. Remove the column email id.
28. Remove the table student.
29. Remove the database kv2.
Page 25 of 25