0% found this document useful (0 votes)
54 views25 pages

Practical File

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 25

Bhonwal Convent School

Computer Science
Python and RDBMS
Practical File
Session: 2023-24

Submitted by: Submitted to:


Divyansh Raj Kureel Mr. Priyanshu Gautam
Class: XII Commerce
Certificate
This is to certify that Divyansh Raj Kureel of class XIIth of
Bhonwal Convent School has completed his project under
my supervision. He has taken proper care and shown
utmost sincerity at completion of this project.
I certify that the project is up to my expectation and as per
guidelines issued by CBSE board.

Teacher: ________________

Examiner: _______________

Principal: _______________
Acknowledgement
I, Divyansh Raj Kureel of class XII comm., would like to
express my sincere gratitude to my computer science
teacher Mr. Priyanshu Gautam, for his vital support,
guidance and encouragement – without which this project
would not have come forth.
I would also like to express my gratitude to my school
Bhonwal Convent School for letting me use the school
laboratory.

Name: Divyansh Raj Kureel


Class: XII Commerce
Session: 2023-24
CBSE Roll no: 23717851
Python
Programmes
1. Write a program to read a file named “article.txt”; count and print the total alphabets in the file.

Coding:

Output:

2. Write a program to know the cursor position and print the text according to the given
specifications:

Coding:

Output:
3. Write a program to read a file named “article.txt”; count and print the following:

a. Length of the file(total characters in file)


Coding:

Output:

b. . Total alphabets
Coding:

Output:

c . Total uppercase alphabets


Coding:

Output:
d . Total lowercase alphabets
Coding:

Output:

e . Total digits
Coding:

Output:

f . Total spaces
Coding:

Output:
g. Total special characters
Coding:

Output:

4. Write a program to read a file named “idiom.txt”;count and print total words starting with “e” or
“E” in the file. (idiom.txt stores: ‘Every cloud has a silver lining’)

Coding:

Output:
5. Write a function that makes a list and returns a new list with unique elements of the first list.
Coding:

Output:

6. Write a function to count the number of uppercase alphabets present in a text file “Practical.txt”.
(Practical.txt stores: ‘This is Class 12 Computer Science Practical File’)

Coding:

Output:

7. Write a program to search for a record to “data.csv” according to the empid input from the user.
Structure of the record saved in “data.csv” is empid, emp_name, dept, salary.
Coding:

Output:

8. Write a program to copy the data from “data.csv” to “temp.csv”. (Assume data in data.csv file)
Coding:

Ouput:
9. Write a program to show the details of the famous quotes stored in the csv file “quotes.csv”
using writerows() function. Data stored in the “quotes.csv” is given below:

Coding:

Output:
10. Write a program to write the following rows and fields in a csv file.
#Field names
Fields=[‘Name’,’Branch’,’Year’,’CGPA’]
#data rows of csv file
rows = [[‘Shyam’,’COE’,’2’,’9.0’],
[‘Garima’,’COE’, ‘2’, ‘9.1’],
[‘Sandeep’, ‘IT’, ‘2’, ‘9.3’],
[‘Chandan’, ‘SE’, ‘1’, ‘9.5’],
[‘Prateek’, ‘IT’, ‘3’, ‘9.8’],
[‘Priyanka’, ‘EP’, ‘2’, ‘9.8’]]
Coding:

Output:
11. Write a menu driven program to maintain book details like book code, book title, and price using
stacks.[Implement push(), pop(), and traverse() functions]
Coding:

Output:
12. Write a function push(number) to add a number (accepted from the user) and pop(number) and
remove a number from a list of numbers, considering them to act as PUSH and POP operations
of the stack data structure.
Coding:

Output:

13. Write a function push() which takes “name” as argument and adds it in a stack names ”MyStack”.
After calling push() three times, a message should be displayed “Stack is Full”.
Coding:

Output:
14. Write add(bookname) and delete() method to add and remove a bookname respectively
considering them to act as push() and pop() operations in a stack.
Coding:

Output:
15. Write a program in Python to read file "story.txt" and copy only those lines to "data.txt" which
are starting from alphabets "A" or "T".

Coding:

Output:
RDBMS – MySQL
Queries
16. Create a table Student and insert data in it. Implement the following SQL commands on the
student table:

a. ALTER table to add new attributes /modify data type/ drop attribute

b. Update table to modify data


Update student set name=”Manshi” where rollno=14;

c. Order by to display data in ascending /descending order


Select * from student order by name acs;
d. DELETE from a tuple(s)
DELETE FROM student
WHERE rollno=8;

e . GROUP BY and find the min, max, sum, Count and average
SELECT
MIN(enroll_no)AS min_age,
MAX(enroll_no) AS max_age,
SUM(enroll_no) AS total_age,
COUNT(*) AS total_students,
AVG(enroll_no) AS avg_age
FROM student;
Python Connection
Interface
17. Write a function to insert a record in a table in MySQL using Python interface
Coding:

Output:
18. Write a function to search a record stored in a table in MySQL using Python interface.

Coding:

Output:
19. Write a program to connect Python with MySQL using database connectivity and perform the:

a. Fetch operations on the data in the database.


Coding:

Output:
b. Update operations on the data in the database.
Coding:

Output:

You might also like