You are on page 1of 48

CS Practical File Session 2023

2023-2024 CLASS 12th

Sarvodya Bal Vidyalaya, Burari


Burari, Delhi – 110084

Computer SCienCe praCtiCal File

Session 2023
2023-2024
2024

Submitted By: Submitted To:


Name: Ujjwal Tyagi S P SHARMA SIR
Roll No: 120259 LECTURER CS/IP
Class & Section:XII--B

GSBV,BURARI 1 UJJWAL TYAGI


CS Practical File Session 2023-2024 CLASS 12 th

S.NO
inDeX
DESCRIPTION Page No. Remark
S.no
PYTHON PROGRAMS
1. WAP in Python to Find the Factorial of a number using function.

2. WAP in Python to implement default and positional parameter.

3. Write a program in Python to input the value of x and n and print the sum of the following series
S.no1+x+x^2+x^3+-----------x^n DESCRIPTION Page No. Remark

4. WAP in python to read a text file and print the number of vowels and consonants in the file

5. WAP in Python to read a text file and print the line or paragraph starting with the letter ‘S’

6. WAP in Python to read a text file and print the number of uppercase and lowercase letters in
The file

7. WAP in Python to create a binary file with name and roll number of the students. Search for
a given roll number and display the name of student

8. Create a binary file with roll_no, name and marks of some students and update the marks of
specific student.

9. Create a binary file with eid, ename and salary and update the salary of the employee

10. Create a text file and remove the lines from the file which contains letter ‘K’

11. Create a binary file with 10 random numbers from 1 to 40 and print those numbers.

12. Write a program in Python to create a CSV file with the details of 5 students.

13. WAP in Python to read a CSV file.

14. Write a menu driven program which insert, delete and display the details of an employee such
as eid, ename and salary using Stack

15. Write a menu driven program which insert, delete and display the details of a book such as
book_id, book_name and price using Stack

16. Write a menu driven program which insert, delete and display the details of a
student such as roll_no, sname and course using Stack.

17. Write a menu driven program which insert, delete and display the details of a movie such as
movie_id, mname and rating using Stack.

18. Write a menu driven program which insert, delete and display the details of a product such as
pid, pname and price using Stack

19. Write a menu driven program which insert, delete and display the details of a club such as
club_id, cname and city using Stack.

GSBV,BURARI 2 UJJWAL TYAGI


CS Practical File Session 2023-2024 CLASS 12 th

20. Write a menu driven program to demonstrate add, display, update, delete and exit. Performed on a
table Book containing (bid, bname, bprice) through python-MySql connectivity

21. Write a menu driven program to demonstrate add, display, update, delete and exit. Performed on
a table Product containing (pid, pname, price) through python-MySql connectivity.

22. Write a menu driven program to demonstrate add, display, update, delete and exit. Performed on a
table club containing (club_id, cname, city) through python-MySql connectivity

23. Write a menu driven program to demonstrate add, display, update, delete and exit. Performed on a
table student containing (sid, sname, course) through python-MySql connectivity.

24. Write a menu driven program to demonstrate add, display, update, delete and exit. Performed on a
table movie containing (mid, mname, rating) through python-MySql connectivity

25. Write a menu driven program to demonstrate add, display, update, delete and exit. Performed on a
table Employee containing (eid, ename, salary) through python-MySql connectivity

MYSQL QUERIES
1. Create a database

2. To create a student table with the student id, class, section, gender, name, dob, and marks as
attributes where the student id is the primary key.

3. To insert the details of at least 10 students in the student table.

4. To delete the details of a particular student in the student table.

5. To increase the marks by 5% for those students who are scoring marks more than 30 .

6. To display the entire content of the table.

7. To display student_id, name and marks of those students who are scoring marks more than 30.

8. To find the average marks from the student table.

9. To find the average marks from the student table.

10. To add a new column email in the student table with appropriate data type

11. To add the email id’s of each student in the previously created email column

12. To display the information of all the students, whose name starts with ‘S’

13. To display the student_id, name, dob of those students who are born between ‘2005-01-01’ and
‘2005-12-31’

14. To display the student_id, name, dob, marks, email of male students in ascending order of their name

15. To display the student_id, gender, name, dob, marks, email of students in descending order of their marks.

16. To display the unique section name from the student table

17. Create a student table with student id, name and marks as attribute, where the student id is the
Primary key

18. Insert the details of 5 students in the student table

19. Delete the details of a student in the student table

20. Use the Select command to get the details of the students with marks more than 30

GSBV,BURARI 3 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

PYTHON PROGRAMS
Practical No-1:: WAP in Python to Find the Factorial of a number using function

OUTPUT:

GSBV,BURARI 4 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-2: WAP in Python to implement default and positional parameter

OUTPUT:

GSBV,BURARI 5 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-3: Write a program in Python to input the value of x and n and print
the sum of the following series

1+x+x^2+x^3+-----------x^n
x^n

OUTPUT:

GSBV,BURARI 6 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-4:WAP
WAP in python to read a text file and print the number of vowels
and consonants in the file

OUTPUT:

GSBV,BURARI 7 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-5: WAP in Python to read a text file and print the line or
paragraph starting with the letter ‘S’

OUTPUT:

GSBV,BURARI 8 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-6: WAP in Python to read a text file and print the number of
uppercase and lowercase letters in the file

OUTPUT:

GSBV,BURARI 9 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-7: WAP in Python to create a binary file with name and roll number of the students.
Search for a given roll number and display the name of student.

OUTPUT:

GSBV,BURARI 10 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-8: Create a binary file with roll_no, name and marks of some students and update the
marks of specific student.

OUTPUT:

GSBV,BURARI 11 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-9: Create a binary file with eid, ename and salary and update the salary of the employee

OUTPUT:

GSBV,BURARI 12 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-10: Create a text file and remove the lines from the file which contains letter ‘K’

OUTPUT:

GSBV,BURARI 13 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-11: Create a binary file with 10 random numbers from 1 to 40 and print those numbers.

OUTPUT:

GSBV,BURARI 14 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-12: Write a program in Python to create a CSV file with the details of 5 students.

OUTPUT:

GSBV,BURARI 15 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-13: WAP in Python to read a CSV file.

OUTPUT:

GSBV,BURARI 16 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-14: Write a menu driven program which insert, delete and display the details of an
employee such as eid, ename and salary using Stack.

OUTPUT:

GSBV,BURARI 17 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-15: Write a menu driven program which insert, delete and display the details of a book
such as book_id, book_name and price using Stack

OUTPUT:

GSBV,BURARI 18 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-16: Write a menu driven program which insert, delete and display the details of a
student such as roll_no, sname and course using Stack.

OUTPUT:

GSBV,BURARI 19 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-17: Write a menu driven program which insert, delete and display the details of a
movie such as movie_id, mname and rating using Stack.

OUTPUT:

GSBV,BURARI 20 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-18: Write a menu driven program which insert, delete and display the details of a
product such as pid, pname and price using Stack

OUTPUT:

GSBV,BURARI 21 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-19: Write a menu driven program which insert, delete and display the details of a club
such as club_id, cname and city using Stack.

OUTPUT:

GSBV,BURARI 22 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-20: Write a menu driven program to demonstrate add, display, update, delete and exit.
Performed on a table Book containing (bid, bn
bname, bprice) through python-MySql
MySql connectivity

GSBV,BURARI 23 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

OUTPUT:

GSBV,BURARI 24 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-21: Write a menu driven program to demonstrate add, display, update, delete and exit.
Performed on a table Product containing (pid, pname, price) through python
python-MySql connectivity.

GSBV,BURARI 25 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

OUTPUT:

GSBV,BURARI 26 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

GSBV,BURARI 27 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practical No-22: Write a menu driven program to demonstrate add, display, update, delete and exit.
Performed on a table club containing (club_id, cname, city) through python
python-MySql
MySql connectivity

GSBV,BURARI 28 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

OUTPUT:

GSBV,BURARI 29 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practicle No 23: Write a menu driven program to demonstrate add, display, update, delete and exit.
Performed on a table student containing (sid, sname, course) through python
python-MySql
MySql connectivity.

GSBV,BURARI 30 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

OUTPUT:

GSBV,BURARI 31 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practicle No 24: Write a menu driven program to demonstrate add, display, update, delete and exit.
Performed on a table movie containing (mid, mname, rating) through python
python-MySql
MySql connectivity

GSBV,BURARI 32 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

OUTPUT:

GSBV,BURARI 33 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Practicle No 25: Write a menu driven program to demonstrate add, display, update, delete and exit.
Performed on a table Employee containing (eid, ename, salary) through python
python-MySql
MySql connectivity

GSBV,BURARI 34 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

OUTPUT:

GSBV,BURARI 35 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

MYSQL QUERIES

Q – 1: Create a database

To create a database we use create database query.

Syntax:

Create database database_name;

To check/show the already created da


databases use the following query
Show databases;

GSBV,BURARI 36 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Q – 2: To create a student table with the student id, class, section, gender, name, dob, and marks as
attributes where the student id is the primary key

Primary key is a constraint of an attribute which cannot be NULL or duplicate. Only one primary
key is allowed in a table.

To create a new table we use create table query.

Syntax:

Create table table_name(col_name1 type primary key, col_name2 type, ……..);

Q – 3: To insert the details of at least 10 students in the student table.

To insert the records in the table we use insert into query

Insert into table_name values(col1_value, col2_value, ……..);

GSBV,BURARI 37 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Q – 4: To delete the details of a particular student in the student table


table.

To delete the specific record from the table use delete command/query.

Syntax:

Delete from table_name where condition;

Note: If we don’t use where clause It delete all the records one by one ffrom
rom the table

GSBV,BURARI 38 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Q – 5: To increase the marks by 5% for those students who are scoring marks more than 30.

Update: Update is a SQL query used to update/change/modify the record of a table.

Syntax

update tablename set col_name=value, col_name=value,... where condition;

Q – 6: To display the entire content of the table.

GSBV,BURARI 39 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Q – 7: To display student_id, name and marks of those students who are scoring marks more than
30.

Q – 8: To find the average marks from the student table.

Aggregate Function:
5 Aggregate function in SQL:
1. SUM() : Find the sum of the values of specific column
2. MAX() : Find the maximum value from the specific column
3. MIN() : Find the minimum value from the specific column
4. AVG() : Find the average of all values from the specific column
5. COUNT() : Count the value from the specific column

GSBV,BURARI 40 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Q – 9: To find the number of students, who are from section ‘A’.

Q – 10: To add a new column email in the student table with appropriate data type.
type

GSBV,BURARI 41 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Q – 11: To add the email id’s of each student in the previously created email column.

GSBV,BURARI 42 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Q – 12: To display the information of all the students, whose name starts with ‘S’
‘S’.

Q – 13: To display the student_id, name, dob of those students who are born between ‘2005-01-01’
‘2005
and ‘2005-12-31’.

GSBV,BURARI 43 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Q – 14: To display the student_id, name, dob, marks, email of male students in ascending order of
their name.

GSBV,BURARI 44 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Q – 15: To display the student_id, gender, name, dob, marks, email of students in descending order
of their marks.

Q – 16: To display the unique section name from the student table.

GSBV,BURARI 45 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Q – 17: Create a student table with student id, name and marks as attribute, where the student id is
the primary key.

Q – 18: Insert the details of 5 students in the student table.

GSBV,BURARI 46 UJJWAL TYAGI


CS Practical File Session 2023
2023-2024 CLASS 12th

Q –19:
19: Delete the details of a student in the student table.

Q –20:
20: Use the Select command to get the details of the students with marks more than 30.
30

GSBV,BURARI 47 UJJWAL TYAGI


CS Practical File Session 2023-2024 CLASS 12 th

GSBV,BURARI 48 UJJWAL TYAGI

You might also like