2. 2
INDEX
SNO. TOPIC TEACHER’S SIGN
1. Write a program to check whether a number
is prime or not.
2. Write a program to check whether a number
is pallindrome or not.
3. Write a program to check whether a string is
pallindrome or not.
4. Write a program to show the statistics of
characters in given line (to count the number
of alphabets , digits , uppercase , lowercase
letters , spaces and other characters ).
5. Write a function to perform linear search in a
list.
6. Write a function to perform binary search in
a list .
7. Write a function to perform sorting in a list .
8. Write a function to remove all odd numbers
from given list.
9. 9.Write a function to display frequencies of
all elements in a list.
10. Write a program to find and display the sum
of all values in a list ending with 3.
11. Write a program in Python to implement a
stack using a list .
3. 3
12. Write a program to read the file content line
by line with each word separated by “#”.
13. Write a program to read the contents of the
file and display the number of vowels ,
consonants , uppercase and lowercase
letters.
14. Write a program to create a binary file to
store roll no and name , search any roll no
and display name if roll no found , otherwise
“Roll not found.
15. Write a program to create binary file to store
roll no , name and marks and update marks
of entered roll no.
16. Write a program to read the content of file
line by line and write it to another file except
for the lines contains letter ‘a’ in it.
17. Write a program to perform read and write
operations in CSV files .
18. MYSQL COMMANDS
7. 7
OUTPUT:
4.Write a program to show the statistics of characters in given line (to count
the number of alphabets , digits , uppercase , lowercase letters , spaces and
other characters ).
11. 11
OUTPUT:
8.Write a function to remove all odd numbers from given list.
OUTPUT:
9.Write a function to display frequencies of all elements in a list.
14. 14
12.Write a program to read the file content line by line with each word
separated by “#”.
OUTPUT:
13.Write a program to read the contents of the file and display the number of
vowels , consonants , uppercase and lowercase letters.
15. 15
OUTPUT:
14.Write a program to create a binary file to store roll no and name , search
any roll no and display name if roll no found , otherwise “Roll not found.
19. 19
16.Write a program to read the content of file line by line and write it to
another file except for the lines contains letter ‘a’ in it.
OUTPUT:
21. 21
MYSQL
Q1: Consider the table TEACHER:
TID NAME AGE DEPT DATEOFJOIN SAL SEX
T101 NAVIN 40 COMPUTER 2010-01-10 12000 M
T102 CHETNA 37 HISTORY 2008-03-24 20000 F
T103 SANDEEP 46 MATHS 2006-12-12 30000 M
T104 SANGEETA 35 HISTORY 2010-07-01 25000 F
T105 NEERAJ 42 MATHS 2004-09-05 40000 M
1. Create the table and insert five records in it.
22. 22
2.To show the information about History department.
3.To list the names of teachers earning salary between 20000 and 30000.
23. 23
4.To count the number of male teachers.
5.Display gender wise total number of teachers
6.To list the name and age of teachers of female teachers in descending order
of date of join.
26. 26
Q2: Consider the table HOSPITAL :
PNO Name Age Dept DateofAdm Charges Sex
1 MAYANK 65 SURGERY 2018-02-23 600 M
2 BABITA 24 ENT 2019-01-01 400 F
3 KASHISH 45 ORTHOPAEDIC 2018-12-19 400 M
4 TARUN 12 SURGERY 2018-10-01 600 M
5 MANISH 36 ENT 2018-01-12 400 F
1.Create the table and insert five records in it.
27. 27
2.To show all the information about the patients of ENT department.
3.To list the names of female patients who are either in ENT or surgery
department.
4.To list the names of all patients with their date of admission in ascending
order.
28. 28
5.To display the patients name , charges , age for female patients.
6.To count number of patients with age>30.
7.To display various departments.
8.To display number of patients in each department.
29. 29
9. To display the details of all patients whose name starts with alphabet ‘M’.
10. To change the age of patients Kashish to 20.
30. 30
11. To increase the charges of all patients by 5%.
12. To remove the record of patient whose name is Tarun.
31. 31
13. To add another column Docname of type varchar in table.
14. To display patient detail whose age is missing.
15.To increase charge by 5% of all patients admitted to ENT department.
32. 32
16.To set charges to NULL for all patients in Surgery department.
17.To display patient details who are giving charges in range 300 and 400
(both inclusive).
33. 33
18.To display details of patient whose name second character contains ‘a’.
19.To display total charges of ENT department.
20.To display details of patients who admitted in year 2019.
21.To display structure of the table.
34. 34
Q3.Consider the following table STUDENT and STREAM :
STUDENT and STREAM
1.Display stream wise total fee collected.
35. 35
2.Count no of students from each area.
3.Display all student details who belong to Madipur area.
4.Increase fee of all students by 10%.
36. 36
5.Display unique area from student table.
6.Display details of those students who area contains ’Puri’.
7.Display all information of those students who are in class XII and section is
either B or C.
37. 37
8.Display class and total fee collected from each class.
9.Display admission number , students name and stream name.
10.Display all student details who have taken Commerce stream.
38. 38
11.Count number of students who have opted for HUMANITIES stream.
12.Display information of Commerce with IP students whose name start with
‘S’ . Arrange therecord by admission number.
13.Display details of all students who are in MEDICAL stream.
14.Display total fee of ‘NON MEDICAL’ students.
39. 39
Q4: Consider the table EMPLOYEE :
EMPLOYEE
ENO NAME DEPARTMENT SALARY
101 ABHAY MGR 25000
102 AAKASH FINANCE 30000
1.Write a program to connect with database and store the above records in
table EMPLOYEE and display them.
40. 40
2.Write a program to connect with the database and search a record based
on Eno , if found display record otherwise display appropriate message.
3.Write a program to connect with the database and update the employee
record of entered employee number.
41. 41
4.Write a program to connect with the database and delete the record of
entered employee number.
AND HERE IS MY CODE FOR THIS QUESTION :
importmysql.connector as ms
mycon=ms.connect(host='localhost',user='root',passwd='parakh',database='sc
hool')
mycursor=mycon.cursor()
defdisplay_all():
print('===========================================================
===========')
global mycon
global mycursor
mycursor.execute('select * from employee')
mydata=mycursor.fetchall()
nrec=mycursor.rowcount
print('total record found are',nrec)
for row in mydata:
print(row)
42. 42
print('===========================================================
===========')
def insert():
print('***********************************************************
************')
global mycon
global mycursor
a=int(input('enter eno no.:'))
b=input('enter name:')
c=input('enter dept name:')
d=int(input('enter salary:'))
query="insert into employee values('{0}','{1}','{2}','{3}')".format(a,b,c,d)
mycursor.execute(query)
mycon.commit()
def search():
print('***********************************************************
************')
global mycon
global mycursor
b=input('ENTER THE ENO NO.:')
query="select * from EMPLOYEE where ENO='{}'".format(b)
mycursor.execute(query)
data=mycursor.fetchone()
if data!=None:
print('-------------------------------------------------------------------')
print(data)
print('-------------------------------------------------------------------')
else:
print('-------------------------------------------------------------------')
print('NO SUCH EMPLOYEE FOUND')
print('-------------------------------------------------------------------')
print('***********************************************************
************')
43. 43
def update():
print('***********************************************************
************')
global mycon
global mycursor
print('WELCOME TO UPDATE COMMAND')
b=input('ENTER THE ENO NUMBER')
query="select* from employee where eno='{}'".format(b)
mycursor.execute(query)
data=mycursor.fetchone()
if data!=None:
print("record found - details are:")
print(data)
ans=input("ARE YOU SURE TO UPDATE salary:(Y/N)")
if ans=='y'orans=='Y':
a=input("ENTER THE SALARY")
query="update employee set salary='{}' where eno='{}'".format(a,b)
mycursor.execute(query)
mycon.commit()
print('updated')
else:
print('SORRY!NO EMPLOYEE FOUND')
def delete():
print('***********************************************************
************')
global mycon
global mycursor
b=input('ENTER THE ENO NUMBER')
query="delete from employee where eno='{}'".format(b)
mycursor.execute(query)
mycon.commit()
print('record deleted')
print('***********************************************************
************')
def customer():
ans='true'
while ans=='true':
print("| *1.display |")
print("| *2.insert |")