SUBMITTED BY SUBMITTED TO
Name: Saanvi Datta Ms. Sapna Thapa (PGT – Computer Science)
Board Roll Number: Internal Teacher’s Sign. & Date:
Class / Section: XII-A
Principal/Vice Principal Sign.
School Stamp:
External Examiner name:
External Examiner’s Sign. & Date
1
INDEX
S.No. Programs’ Name Page Remarks
No.
1. Generate the patterns using nested loop. 4-6
2. Write a Python program to compute the greatest common divisor 7
(GCD) and least common multiple (LCM) of two integers.
3. Write a Python program to check for palindrome of string using for 8
and if-else loop.
4. Write a Python program to find the largest/ smallest number in an 9-10
empty list/tuple.
5. Create an empty list in python program to search given elements in 11
the created list.
6. Create a dictionary with roll number, name and marks of n students in 12
a class and display the names of students who have scored marks
above 95 in python.
7. Write a python program using the function to print the Fibonacci 13
series up to n numbers.
8. Write a python program to enter a temperature in Celsius into 14
Fahrenheit by using the function.
9. Create a dictionary in python shown at below: 15
dt={'Bhavna':1,"Richard":2,"Firoza":3,"Arshnoor":4} and ask the user
to enter any key to check whether a value exists in dictionary or not.
10. Program to pass a list as function argument and modify it and return 16
to the function.
11. Create a user define module name (mymodule.py) and define any 3 17-18
functions inside it that will perform some specific tasks of your choice
and call/ use all the define function of mymodule.py in another
program names as (modulecall.py)
12. Write a function push(student) and pop(student) to add a new student 19
name and remove a student name from a list student, considering
them to act as PUSH,POP,DISPLAY,PEAK,REVERSE operations of stack
Data Structure in Python.
13. Write a function push(number) and pop(number) to add a number 20
(Accepted from the user) and remove a number from a list of
numbers, considering them act as PUSH,POP,DISPLAY,PEAK,REVERSE
operations of Data Structure in Python.
2
14. Write a menu-based program to add, delete and display the record of 21
hostel using list as stack data structure in Python. Record of hostel
contains the fields: Hostel number, Total students and Total room.
15. Write a function Push() which takes ‘name’ as argument ad add in a 22
stack named ‘MyStack’. After calling Push() three times, a message
should be displayed ‘Stack is Full’.
16. Write a program to insert the elements in empty stack only if the 23
inserted element by user is odd number. Also print the largest number
among the inserted stack elements.
17. Vedika has created a dictionnary containing names and marks as key- 24
value pairs of 5 students. Write a program, with separate user defined
functions to perform the following operations.
18. Write two methods or functions in python respectively Write_Data() 25
to create a new file and Show_Words() to read lines from a newly
created text file and the file name is POEM.txt and display those
words, which are less than 4 characters.
19. Write a program to perform read and write operation onto a 26
RECORD.csv file having fields as roll number, name, stream and
percentage enter by the user. After writing the record in CSV, read all
the records and display their content.
20. Create a binary file named STUDENT.dat with any 3 names and roll 27-28
number of student. Search for a given roll number and display the
name, if not found display appropriate message.
21. Assume that you have previously created a binary structured data in 29
‘Stu_rec.dat’ file that containing the following structure like
[Roll_Number, Student_Name]. Now you want to add more record in
the same file ‘Stu_rec.dat’. Write a function addrec() in python to add
more records at the bottom of the same binary file.
22. Write SQL commands for (a) to (f) and write the output for (g) on the 30-33
basis of table HOSPITAL.
23. Write SQL commands for (a) to (f) and write the output for (g) on the 34-36
basis of table HOSPITAL.
24. Write SQL commands for(I) to (VII) on the basis of table SPORTS. 37-39
25. Write SQL commands to join table student and teacher. 40-41
26 Write a program to demonstrate four operations performed on a table 42-43
through MySQL-Python connectivity.
3
Q1. Generate the following patterns using nested loop.
(i)
INPUT:
OUTPUT:
4
(ii)
INPUT:
OUTPUT:
5
(iii)
INPUT:
OUTPUT:
6
Q2. Write a Python program to compute the greatest common
divisor (GCD) and least common multiple (LCM) of two integers.
INPUT:
OUTPUT:
7
Q3. Write a Python program to check for palindrome of string using
for and if-else loop.
INPUT:
OUTPUT:
8
Q4. Write a Python program to find the largest/ smallest number in
an empty list/tuple.
(i)
INPUT:
OUTPUT:
9
(ii)
INPUT:
OUTPUT:
10
Q5. Create an empty list in python program to search given elements
in the created list.
INPUT:
OUTPUT:
11
Q6. Create a dictionary with roll number, name and marks of n
students in a class and display the names of students who have
scored marks above 95 in python.
INPUT:
OUTPUT:
12
Q7. Write a python program using the function to print the Fibonacci
series up to n numbers.
INPUT:
OUTPUT:
13
Q8. Write a python program to enter a temperature in Celsius into
Fahrenheit by using the function.
INPUT:
OUTPUT:
14
Q9. Create a dictionary in python shown at below:
dt={'Bhavna':1,"Richard":2,"Firoza":3,"Arshnoor":4} and ask the user
to enter any key to check whether a value exists in dictionary or not.
INPUT:
OUTPUT:
15
Q10. Program to pass a list as function argument and modify it and
return to the function.
INPUT:
OUTPUT:
16
Q11. Create a user define module name (mymodule.py) and define
any 3 functions inside it that will perform some specific tasks of your
choice and call/ use all the define function of mymodule.py in
another program names as (modulecall.py)
INPUT1:
INPUT2:
17
OUTPUT:
18
Q12. Write a function push(student) and pop(student) to add a new
student name and remove a student name from a list student,
considering them to act as PUSH, POP, DISPLAY, PEAK, REVERSE
operations of stack Data Structure in Python.
INPUT:
OUTPUT:
19
Q13. Write a function push(number) and pop(number) to add a
number (Accepted from the user) and remove a number from a list
of numbers, considering them act as PUSH, POP, DISPLAY, PEAK,
REVERSE operations of Data Structure in Python.
INPUT:
OUTPUT:
20
Q14. Write a menu-based program to add, delete and display the
record of hostel using list as stack data structure in Python. Record of
hostel contains the fields: Hostel number, Total students and Total
room.
INPUT:
OUTPUT:
21
Q15. Write a function Push() which takes ‘name’ as argument ad add
in a stack named ‘MyStack’. After calling Push() three times, a
message should be displayed ‘Stack is Full’.
INPUT:
OUTPUT:
22
Q16. Write a program to insert the elements in empty stack only if
the inserted element by user is odd number. Also print the largest
number among the inserted stack elements.
INPUT:
OUTPUT:
23
Q17. Vedika has created a dictionary containing names and marks as
key-value pairs of 5 students. Write a program, with separate user
defined functions to perform the following operations:
1) Push the keys (name of the student) of the dictionary into a stack,
where the corresponding value (marks) is greater than 70.
2) Pop and display the content of the stack.
INPUT:
OUTPUT:
24
Q18. Write two methods or functions in python respectively
Write_Data() to create a new file and Show_Words() to read lines
from a newly created text file and the file name is POEM.txt and
display those words, which are less than 4 characters.
INPUT:
OUTPUT:
25
Q19. Write a program to perform read and write operation onto a
RECORD.csv file having fields as roll number, name, stream and
percentage enter by the user. After writing the record in CSV, read all
the records and display their content.
INPUT:
OUTPUT:
26
Q20. Create a binary file named STUDENT.dat with any 3 names and
roll number of student. Search for a given roll number and display
the name, if not found display appropriate message.
INPUT:
27
OUTPUT:
28
Q21. Assume that you have previously created a binary structured
data in ‘Stu_rec.dat’ file that containing the following structure like
[Roll_Number, Student_Name]. Now you want to add more record in
the same file ‘Stu_rec.dat’. Write a function addrec() in python to
add more records at the bottom of the same binary file.
INPUT:
OUTPUT:
29
Q22. Write SQL commands for (a) to (f) and write the output for (g)
on the basis of table HOSPITAL.
30
(a) To show all information about the patients of cardiology department.
(b) To list the names of female patients who are in orthopedic dept
(c) To list names of all patients with their date of admission in ascending order.
31
(d) To display Patient’s Name, Charges, age for male patients only.
(e) To count the number of patients with age >20.
(f) To insert a new row in the HOSPITAL table with the following data:
11,”Mustafa”,37,”ENT”,{25/02/98},250,”M”
(g) Give the output of following SQL statement:
(i) Select COUNT (distinct departments) from HOSPITAL;
32
(ii) Select Max(Age) from HOSPITAL where SEX = “M”;
(iii) Select AVG(Charges) from HOSPITAL where SEX = “ F”;
(iv) Select SUM(Charges) from HOSPITAL where Datofadm;
33
Q23. Write SQL commands for (a) to (f) and write the output for (g)
on the basis of table EMPLOYEE.
(a) To show all information about the employees of Engg. Branch
34
(b) To list the names of female employees who are in Science branch.
(c) To list the names of all employees with their date of retirement in
ascending order.
(d) To display Employee’s name ,Salary ,Age for male employees only.
35
(e) To count the number of employees with AGE > 33.
(f) To insert a new row in the EMPLOYEE table with the following data:
9,”Rohit”,46,”language”,{22/06/98},2300,”M”
(g) Give the output of the following SQL statements:
(i) Select COUNT(distinct department) from EMPLOYEE;
(ii) Select MAX(Age) from EMPLOYEE where SEX =”F”;
36
Q24. Write SQL commands for(I) to (VII) on the basis of table
SPORTS.
(i) Display the names of the students who have grade ‘C’ in either Game1 or
Game2 or both.
37
(ii)Display the number of students getting grade ‘A’ in Cricket.
(iii)Display the names of the students who have same game for both Game1
and Game2.
(iv)Display the games taken up by the students, whose name starts with ‘A’.
(v) Add a new column named ‘ Marks’.
38
(vi) Assign a value 200 for marks for all those who are getting grade ‘B’ or
grade ‘ A’ in both Game1 and game2.
(vii) Arrange the whole table in the alphabetical order of Name.
39
Q25. Write SQL commands to join table student and teacher.
i) Cartesian Join
ii) Equi Join
40
iii) Left Join
iv)Right Join
41
Q26. Write a program to demonstrate four operations performed on
a table through MySQL-Python connectivity.
INPUT:
42
OUTPUT:
In MySQL,
43