SlideShare a Scribd company logo
1 of 44
1
MAMTA MODERN SR.
SEC. SCHOOL
2022-23
COMPUTER SCIENCE PRACTICAL
FILE(Python-083)
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
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
4
PYTHON
1. Write a program to check whether a number is prime or not.
5
OUTPUT:
2.Write a program to check whether a number is pallindrome or not.
OUTPUT:
6
3.Write a program to check whether a string is pallindrome or not.
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 ).
8
OUTPUT:
5.Write a function to perform linear search in a list .
9
OUTPUT:
6.Write a function to perform binary search in a list .
10
OUTPUT:
7.Write a function to perform sorting in a list .
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.
12
OUTPUT:
10.Write a program to find and display the sum of all values in a list ending
with 3.
OUTPUT:
13
11.Write a program in Python to implement a stack using a list .
OUTPUT:
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
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.
16
OUTPUT:
17
15.Write a program to create binary file to store roll no , name and marks
and update marks of entered roll no.
18
OUTPUT:
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:
20
17.Write a program to perform read and write operations in CSV files .
OUTPUT:
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
2.To show the information about History department.
3.To list the names of teachers earning salary between 20000 and 30000.
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.
24
7.Increase the salary by 10% for Maths department.
25
8.To delete the record of teacher Neeraj.
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
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
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
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
11. To increase the charges of all patients by 5%.
12. To remove the record of patient whose name is Tarun.
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
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
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
Q3.Consider the following table STUDENT and STREAM :
STUDENT and STREAM
1.Display stream wise total fee collected.
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
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
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
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
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
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
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
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
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 |")
44
print("| *3.search |")
print("| *4.update |")
print("| *5.delete |")
a=int(input('Enter the number:'))
if a==1:
display_all()
elif a==2:
insert()
elif a==3:
search()
elif a==4:
update()
elif a==5:
delete()
a=customer()

More Related Content

Similar to sample practical file 2022-23 aniket choudhary.docx

information practices cbse based paper.docx
information practices cbse based paper.docxinformation practices cbse based paper.docx
information practices cbse based paper.docxKapilSidhpuria3
 
computer science practical.pdf
computer science practical.pdfcomputer science practical.pdf
computer science practical.pdfekjot0723
 
Data Structure.pdf
Data Structure.pdfData Structure.pdf
Data Structure.pdfMemeMiner
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arraysenidcruz
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptMehul Desai
 
C and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfC and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfjanakim15
 
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21chinthala Vijaya Kumar
 
ABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.infoABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.infosapdocs. info
 
best notes in c language
best notes in c languagebest notes in c language
best notes in c languageIndia
 
Cs8261 cp lab syllabus
Cs8261 cp lab syllabusCs8261 cp lab syllabus
Cs8261 cp lab syllabusPalani Chamy
 
Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C LabNeil Mathew
 
Ge6161 lab manual
Ge6161 lab manualGe6161 lab manual
Ge6161 lab manualMani Kandan
 
Oop lab assignment 01
Oop lab assignment 01Oop lab assignment 01
Oop lab assignment 01Drjilesh
 
Assignment 1Specific Instructions for this Assignment There i.docx
Assignment 1Specific Instructions for this Assignment There i.docxAssignment 1Specific Instructions for this Assignment There i.docx
Assignment 1Specific Instructions for this Assignment There i.docxtrippettjettie
 
Compiler design-lab-manual v-cse
Compiler design-lab-manual v-cseCompiler design-lab-manual v-cse
Compiler design-lab-manual v-cseravisharma159932
 
C programming language
C programming languageC programming language
C programming languageAbin Rimal
 

Similar to sample practical file 2022-23 aniket choudhary.docx (20)

information practices cbse based paper.docx
information practices cbse based paper.docxinformation practices cbse based paper.docx
information practices cbse based paper.docx
 
computer science practical.pdf
computer science practical.pdfcomputer science practical.pdf
computer science practical.pdf
 
CS8391 Data Structures Part B Questions Anna University
CS8391 Data Structures Part B Questions Anna UniversityCS8391 Data Structures Part B Questions Anna University
CS8391 Data Structures Part B Questions Anna University
 
Data Structure.pdf
Data Structure.pdfData Structure.pdf
Data Structure.pdf
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arrays
 
Java programlist (1)
Java programlist (1)Java programlist (1)
Java programlist (1)
 
C-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.pptC-Programming Chapter 1 Fundamentals of C.ppt
C-Programming Chapter 1 Fundamentals of C.ppt
 
C and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfC and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdf
 
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
 
ABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.infoABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.info
 
best notes in c language
best notes in c languagebest notes in c language
best notes in c language
 
Cs8261 cp lab syllabus
Cs8261 cp lab syllabusCs8261 cp lab syllabus
Cs8261 cp lab syllabus
 
Mmt 001
Mmt 001Mmt 001
Mmt 001
 
Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C Lab
 
Ge6161 lab manual
Ge6161 lab manualGe6161 lab manual
Ge6161 lab manual
 
Cp manual final
Cp manual finalCp manual final
Cp manual final
 
Oop lab assignment 01
Oop lab assignment 01Oop lab assignment 01
Oop lab assignment 01
 
Assignment 1Specific Instructions for this Assignment There i.docx
Assignment 1Specific Instructions for this Assignment There i.docxAssignment 1Specific Instructions for this Assignment There i.docx
Assignment 1Specific Instructions for this Assignment There i.docx
 
Compiler design-lab-manual v-cse
Compiler design-lab-manual v-cseCompiler design-lab-manual v-cse
Compiler design-lab-manual v-cse
 
C programming language
C programming languageC programming language
C programming language
 

Recently uploaded

COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Celine George
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonhttgc7rh9c
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17Celine George
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfElizabeth Walsh
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfKartik Tiwari
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 

Recently uploaded (20)

COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdf
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 

sample practical file 2022-23 aniket choudhary.docx

  • 1. 1 MAMTA MODERN SR. SEC. SCHOOL 2022-23 COMPUTER SCIENCE PRACTICAL FILE(Python-083)
  • 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
  • 4. 4 PYTHON 1. Write a program to check whether a number is prime or not.
  • 5. 5 OUTPUT: 2.Write a program to check whether a number is pallindrome or not. OUTPUT:
  • 6. 6 3.Write a program to check whether a string is pallindrome or not.
  • 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 ).
  • 8. 8 OUTPUT: 5.Write a function to perform linear search in a list .
  • 9. 9 OUTPUT: 6.Write a function to perform binary search in a list .
  • 10. 10 OUTPUT: 7.Write a function to perform sorting in a list .
  • 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.
  • 12. 12 OUTPUT: 10.Write a program to find and display the sum of all values in a list ending with 3. OUTPUT:
  • 13. 13 11.Write a program in Python to implement a stack using a list . OUTPUT:
  • 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.
  • 17. 17 15.Write a program to create binary file to store roll no , name and marks and update marks of entered roll no.
  • 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:
  • 20. 20 17.Write a program to perform read and write operations in CSV files . 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.
  • 24. 24 7.Increase the salary by 10% for Maths department.
  • 25. 25 8.To delete the record of teacher Neeraj.
  • 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 |")
  • 44. 44 print("| *3.search |") print("| *4.update |") print("| *5.delete |") a=int(input('Enter the number:')) if a==1: display_all() elif a==2: insert() elif a==3: search() elif a==4: update() elif a==5: delete() a=customer()