0% found this document useful (0 votes)
7 views46 pages

CS PRACTICAL FILE

The document is a practical file for Computer Science students at The Adarsh School for the academic year 2024-2025, authored by Krishna Gupta. It includes a comprehensive index of Python programs and MySQL queries that cover various topics such as file handling, data manipulation, and database operations. Each program and query is designed to enhance students' understanding and application of computer science concepts.

Uploaded by

sagarcapri71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views46 pages

CS PRACTICAL FILE

The document is a practical file for Computer Science students at The Adarsh School for the academic year 2024-2025, authored by Krishna Gupta. It includes a comprehensive index of Python programs and MySQL queries that cover various topics such as file handling, data manipulation, and database operations. Each program and query is designed to enhance students' understanding and application of computer science concepts.

Uploaded by

sagarcapri71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

THE ADARSH

SCHOOL

COMPUTER SCIENCE
PRACTICAL FILE
2024-2025

Submitted by:
KRISHNA GUPTA
XII A
INDEX
S No. Python Programs Page
No.
Write a program to get roll numbers, names and marks of the students of a class 4
1. (get from user) and store these details in a file called “marks.txt”
Write a program to read a text file and display the number of vowels, consonants, 5
2. uppercase and lowercase characters in the file.
Write a program to remove all the lines that contain the character 'a' in a file and 6
3. write it to another file.
Write a method in python to write multiple line of text contents into a text file 7
4. mylife.txt.
Create a binary file with name and roll number. Search for a given roll number and 8
5. display the name, if not found display appropriate message.
Create a binary file with roll number, name and marks. Input a roll number and 9
6. update the marks.
Write a program to a binary file called emp.dat and write into it the employee 10
7. details of some employees, available in the form of dictionaries.

Write a menu drive program in python to implement stack using a list and perform 11
8. following functions – Push, Pop, Display, Peek and Exit.
9. Write a program to display unique vowels present in the given word using Stack. 13
Write a Program to enter the numbers in a list using split () and to use all the 14
10. functions related to list.
11. Write a program to count Even and Odd numbers in a list. 15

Write a program to connect with database and store record of employee and display 16
12. records.
Write a program to connect with database and search employee number in table 18
13. employee and display record, if employee number not found display appropriate
message.
Write a program to connect with database and update the employee record of 19
14. entered employee number.
Write a program to connect with database and delete the record of entered 20
15. employee number.
Write a program to read the following details of sports performance (sport, 21
16. competitions, prizes‐won) of your school and store into a csv file delimited with tab
character.
Write a program to get item details(code, description and price) for multiple items 22
17. from the user and create a csv file by writing all the items details in one go.
Write a program that checks for presence of a value inside a dictionary and prints its 23
18. key.
Write a program to find the occurrence of any word in a string. 24
19.
Write a program to find nth term of Fibonacci series 25
20. ( 0,1,1,2,3,5,8,13,21,34,55,89,... ) .
Write a program to input any number from user and check it is a prime number or 26
21. not.
MySQL
Table: Student
1. Write a query to update the Marks for student with attribute Physics for the student 27
106.
2. Write a query to order the table in descending order using attribute chemistry. 28
3. Write a query to order the table in ascending order using attribute chemistry. 28
4. Write a query to delete a tuple from student whose roll no is 101. 29
5. Write a query to add a new attribute Branch to the table student. 29
6. Write a query to drop the attribute branch from the table student. 30
7. Write a query to find the minimum marks in maths. 30
8. Write a query to find the maximium marks in physics. 30
9. Write a query to find the sum of marks in chemistry. 31
10. Write a query to count the roll no in the table student. 31
Table: Books
1. Table: Issued 32
Write a query to show Book name, Author name and Price of books of First Publ.
publishers.
Write a query to display the names and price from books in ascending order of their
2. price. 33
3. Write a query to increase the price of all books of EPB Publishers by 50. 33
Write to display the Book_Id, Book_Name and Quantity_Issued for all books which
4. have been issued. 33
Table: Passenger
1. Table: Flight
Write a query to change the fare to 5000 of the flight whose FNO is F104. 34
2. Write a query to display the total number of Male and Female Passengers. 35
Write a query to display the Name, corresponding Fare and F_Date of all passengers
3. who have a fight to start from Delhi. 35
4. Write a query to delete the records of flights which end at Mumbai. 35
1. Table:Teacher 36
Table: Admin
Write a query to display the name of the teacher and their designation.
2 Write a query to display the name and subjects of all female teachers. 37
3. Write a query to display the all details of all teachers including gender and 37
designation.
4. Write a query to display the details of all hod. 37
TABLE: GYM
To create the table
1 38
2 To display the names of all items whose name starts with”A”

3 To display Icodes and Inames of all items whose Brandname is Reliable or


Coscore

4 To change the Brandname to “FIT TREND INDIA” of the item whose Icode
as “G101”

5 Add a new row for new item in GYM withdetails


IcodeG107,InameTredmil,Price-40000,Brandname-Samsung
TABLE: WORKER
TABLE:ISSUED
Display name and designation of those workers whose p.level is
1 “P001” or “P002”

2 Display the details of all workers in descending order of ‘DOB’

3 Display the content of worker whose DOB lies in between 19/JAN/1984 to


18/JAN/1987

4 Display the designation wise count

5 Display DOJ and pay of all operators

6 Change the pay of code “P002” by adding 5% to it

OUTPUTS FINDING
Select count(distinct paylevel) from worker;
7(i)
7(ii) Select name,allowance from worker,paylevel where worker.paylevel =
paylevel.paylevel;
QUESTTION 1: W Write a prrogram too get rolll numbers
rs, namess and
marks of the students off a class ((get fromm user) an
nd store tthese
detailss in a file called “m
marks.txtt”

OUTPU
UT:
Question 2:
Write a program to read a text file and display the number of
vowels, consonants, uppercase and lowercase characters in the file.

Output :
Question 3:
Write a program to remove all the lines that contain the character
'a' in a file and write it to another file.

Output :

New.txt file ‐

Writenew.txt file ‐
Question 4:
Write a method in python to write multiple line of text contents
into a text file mylife.txt.

Output :
Question 5:
Create a binary file with name and roll number. Search for a given
roll number and display the name, if not found display appropriate
message.

Output :
Question 6:
Create a binary file with roll number, name and marks. Input a roll
number and update the marks.

Output :
Question 7:
Write a program to a binary file called emp.dat and write into it the
employee details of some employees, available in the form of
dictionaries.

Output:
Question 8:
Write a menu drive program in python to implement stack using a
list and perform following functions – Push, Pop, Display, Peek and
Exit
Output:
Question 9:
Write a program to display unique vowels present in the given word
using Stack.

Output :
Question 10:
Write a Program to enter the numbers in a list using split () and to
use all the functions related to list.

Output :
Question 11:
Write a program to count Even and Odd numbers in a list.

Output :
Question 12:
Write a program to connect with database and store record of
employee and display records.
Output :

MySQL Output:
Question 13:
Write a program to connect with database and search employee
number in table employee and display record, if employee number
not found display appropriate message.

Output:
Question 14: Write a program to connect with database and update
the employee record of entered employee number.

Output:
Question 15:
Write a program to connect with database and delete the record of
entered employee number.

Output :
Question 16:
Write a program to read the following details of sports
performance (sport, competitions, prizes‐won) of your school and
store into a csv file delimited with tab character.

Output:
Question 17:
Write a program to get item details(code, description and price) for
multiple items from the user and create a csv file by writing all the
items details in one go.

Output:
Question 18:
Write a program that checks for presence of a value inside a
dictionary and prints its key.

Output:
Question 19:
Write a program to find the occurrence of any word in a string.

Output:
Question 20:
Write a program to find nth term of Fibonacci series (
0,1,1,2,3,5,8,13,21,34,55,89,... ) .

Output:
Question 21:
Write a program to input any number from user and check it is a
prime number or not.

Output:
MySQL

Table: Student

Question 1:
Write aquery to update the Marks for student with attribute
Physics for the student 106.
Question 2:
Write a query to order the table in descending order using attribute
chemistry.

Question 3:
Write a query to order the table in ascending order using attribute
chemistry.
Question 4:
Write a query to delete a tuple from student whose roll no is 101.

Question 5:
Write a query to add a new attribute Branch to the table student.
Question 6:
Write a query to drop the attribute branch from the table student.

Question 7:
Write a query to find the minimum marks in maths.

Question 8:
Write a query to find the maximium marks in physics.
Question 9:
Write a query to find the sum of marks in chemistry.

Question 10:
Write a query to count the roll no in the table student.

Question 11:
Write a query to find the average marks in maths.
Table: Books

Table: Issued

Question 1:
Write a query to show Book name, Author name and Price of books
of First Publ. publishers.
Question 2:
Write a query to display the names and price from books in
ascending order of their price.

Question 3:
Write a query to increase the price of all books of EPB Publishers by
50.
Question 4:
Write to display the Book_Id, Book_Name and Quantity_Issued for
all books which have been issued.
Table: Passenger

Table: Flight

Question 1:
Write a query to change the fare to 5000 of the flight whose FNO is
F104.
Question 2:
Write a query to display the total number of Male and Female
Passengers.

Question 3:
Write a query to display the Name, corresponding Fare and F_Date
of all passengers who have a fight to start from Delhi.

Question 4:
Write a query to delete the records of flights which end at Mumbai.
Table: Teacher
Table: Admin

Question 1:
Write a query to display the name of the teacher and their
designation.
Question 2:
Write a query to display the name and subjects of all feteachers.

Question 3:
Write a query to display the all details of all teachers including
gender and designation.
Question 4:
Write a query to display the details of all hod.
Table : GYM

Question 1:
To create the table.`

Question 2:
To display the names of all items whose name starts with ‘A’.
Question 3:
To display Icode and Inames of all items whose Brandname is
Reliable or Coscore.

Question 4:
To change the Brandname to “FIT TREND INDIA” of the
item,whose Icode as “G101”.

Question 5:
Add a new row for new item in GYM with details
Icode-G107,Iname-Tredmil,Price-40000,Brandname-Samsung.
Table: Worker

Table: Paylevel

Question 1:
Display name and designation of those workers whose P.level is
‘P001’or ‘P002’.
Question 2:
Display the details of all workers in descending order of ‘DOB”.

Question 3:
Display the content of worker whose DOB lies in between
19/JAN/1984 to 18/JAN/1987.

Question 4:
Display the designation wise count.

Question 5:
Display DOJ and PAY of all operators.
Question 6:
Change the pay of code “P002” by adding 5% to it.

OUTPUT FINDING:-
Question 7(i):
Select count(distinct P.level) from worker;

Question 7(ii):
Select name,allowance from worker,paylevel where
worker.paylevel=paylevel.paylevel;

You might also like