0% found this document useful (0 votes)
13 views9 pages

Practical File 2025-2026

The document contains a comprehensive list of programming tasks and exercises primarily focused on Python, file handling, and SQL queries. It includes tasks for creating programs to check palindromes, perform calculations, manipulate text files, and manage binary files, as well as various SQL queries for database operations. The tasks are structured to enhance understanding of programming concepts and database management.

Uploaded by

arnav4442
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)
13 views9 pages

Practical File 2025-2026

The document contains a comprehensive list of programming tasks and exercises primarily focused on Python, file handling, and SQL queries. It includes tasks for creating programs to check palindromes, perform calculations, manipulate text files, and manage binary files, as well as various SQL queries for database operations. The tasks are structured to enhance understanding of programming concepts and database management.

Uploaded by

arnav4442
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/ 9

1.​ Write a program to check a number whether it is palindrome or not.

2.​ Write a program to display ASCII code of a character and vice versa.
3.​ Program to make a simple calculator.
4.​ Example of Global and Local variables in function
5.​ Python program to count the number of vowels, consonants, digits and special
characters in a string.
6.​ Python Program to add marks and calculate the grade of a student
7.​ Generating a List of numbers Using For Loop
8.​ Write a program to read a text file line by line and display each word separated by '#'.
9.​ Read a text file and display the number of vowels/ consonants/ uppercase/ lowercase
characters and other than character and digit in the file.
10.​Write a Python code to find the size of the file in bytes, the number of lines, and number
of words and no. of character.
11.​ Write a method in python to write multiple lines of text contents into a text file mylife.txt.
12.​ Write a function in Python to read lines from a text file diary.txt, and display only those
lines, which are starting with an alphabet 'P'.

If the contents of file is :

I hope you will please write to me from all the cities you visit.

Please accept them with the love and good wishes of your friend.

He never thought something so simple could please him so much.

The output should be:

Please accept them with the love and good wishes of your friend.

13.​Write a method in Python to read lines from a text file INDIA.TXT, to find and display the
occurrence of the word 'India'. For example, if the content of the file is:

India is the fastest-growing economy. India is looking for more investments around the
globe. The whole world is looking at India as a great market. Most of the Indians can
foresee the heights that India is capable of reaching.

The output should be 4.

14.​Assuming that a text file named first.txt contains some text written into it, write a function
that reads the file first.txt and creates a new file named second.txt, to contain only those
words from the file first.txt which start with a lowercase vowel (i.e. with 'a', 'e', 'i', 'o', 'u').

For example if the file first.txt contains


Carry umbrella and overcoat when it rains

Then the file second.txt shall contain umbrella and overcoat it

Write a function in Python to count and display the number of vowels in a text file.

15.​A binary file “student.dat” has structure [rollno,name, marks].

i. Write a user defined function insertRec() to input data for a student and add to
student.dat.

ii. Write a function searchRollNo( r ) in Python which accepts the student’s rollno as
parameter and searches the record in the file “student.dat” and shows the details of
student i.e. rollno, name and marks (if found) otherwise shows the message as ‘No
record found’.

16.​ A binary file “emp.dat” has structure [EID,Ename, designation, salary].

i. Write a user defined function CreateEmp() to input data for a record and create a file
emp.dat.

ii. Write a function display() in Python to display the detail of all employees whose salary
is more than 50000.

17.​A binary file “Book.dat” has structure [BookNo, Book_Name, Author, Price].

i. Write a user defined function CreateFile() to input data for a record and add to
“Book.dat” .

ii. Write a function CountRec(Author) in Python which accepts the Author name as
parameter and count and return number of books by the given Author are stored in the
binary file “Book.dat”.

18.​A binary file “STUDENT.DAT” has structure (admission_number, Name, Percentage).


Write a function countrec() in Python that would read contents of the file
“STUDENT.DAT” and display the details of those students whose percentage is above
75. Also display the number of students scoring above 75%.

19.​ A binary file named “EMP.dat” has some records of the structure [EmpNo, EName, Post,
Salary]

(a) Write a user-defined function named NewEmp() to input the details of a new
employee from the user and store it in EMP.dat.
(b) Write a user-defined function named SumSalary(Post) that will accept an argument
the post of employees & read the contents of EMP.dat and calculate the SUM of salary
of all employees of that Post.

20. A binary file “Items.dat” has structure as [ Code,Description, Price ].

i. Write a user defined function MakeFile( ) to input multiple items from the user and add
to Items.dat

ii. Write a function SearchRec(Code) in Python which will accept the code as parameter
and search and display the details of the corresponding code on screen from Items.dat.

21. Write a python program to create a csv file dvd.csv and write 10 records in it Dvd

id,dvd name,qty,price. Display those dvd details whose dvd price is more than 25.

22. Write a program to search the record from "data.csv" according to the admission
number input from the user. The structure of the record saved in "data.csv" is [ Admno,
Name,Class, Section,Marks].

23. Write a program to insert the record in the file "data.csv". The record structure is:
{FurnitureCode, FurnitureName, Price}

24. Write a program to display the records from "Prodcut.csv" file where the price is
more than 300. The structure saved in the file is [Productid, Productname, Price]

25. Write a program to count the number of records present in "data.csv".

26. Write a program to modify the record present in "data.csv". The structure of the
record is [RollNum, Name, Marks]

27. Write a Program to show MySQL database connectivity in python


28. Write a Python program to implement all basic operations of a stack, such as adding
element (PUSH operation), removing element (POP operation) and displaying the stack
elements (Traversal operation) using lists.

29. Write a menu driven program to store and manipulate data in binary files to insert,
update, delete and display records. The data has following structure: Data Represents
Patient Information Dictionary {‘P_ID’:101,’P_Name’:’Shiv’,’Charges’:25000}

File Name patient.dat

Menu: 1. Add Patient 2. Display Patient 3. Search Patient 4. Update Patient 5. Delete
Patient 6. Exit

30. Create a CSV file by entering user-id and password, read and search the password for
given userid.

31. Write a program to Push an item into stack where a dictionary contains the details of
stationary items as follows: stn = {“Shirt”:700,”T-Shirt”:750,”Jeans”:1150,”Trouser”:400}
(a) Write a function to push an element into the stack for those item names whose price is more
than 850. Also display the count of elements pushed into the stack.
(b) Write a function to pop an element to remove the element and display appropriate messages
when the stack is empty.

32.

1. Create above table, assign Movie_ID as a primary key and insert records as above
2. Show the structure of table
3. Add a column named collection with decimal data type with structure 12, 2
4. Change the data type of movie_id to varchar
5. Rename a column MovieName to MName
6. Delete a column collection
7. Display the movie name, type, releasedate and total cost of all movies
8. Display all details of action and thriller movies
9. Display movie name, types and releasedate of all movies released in the month of February,
2022
10. Display the details of movies whose name ends with letter k.
11. Display the details of movies which is not released yet
12. Display the movie name type release date and production cost in the descending order of
production cost
13. Display the number of movies for each type
Display the number of unique movies
14. Display the maximum production cost for each movie type
15. Display the date of movies released latest
16. Display the average business cost of movies for each type
17. Display the type and number of movies for each type where movie type is more than two

33. Write​ SQL queries for (i) to​ (iv) and find outputs for SQL​queries​ (v) to (viii),
which are​ based on the tables

TABLE: VEHICLE
(i).​ To display NO, NAME, TDATE from the table TRAVEL in descending order of​ NO.
(ii).​ To display the​ NAME​ of all the travellers from the table TRAVEL​ who are traveling by​
vehicle​with code 101​ or 102.
(iii).​ To display the​ NO and NAME of those travellers from the​ table TRAVEL who travelled​
between ‘2015-12-31’​and ‘2015-04-01’.
(iv) To​ display​all the​ details​ from table TRAVEL for the travellers,who have travelled
Distance more​than 100 KM​ in ascending​ order of NOP.
(v).​ SELECT COUNT(*),​ CODE​ FROM​TRAVEL GROUP BY CODE HAVING​
COUNT(*)>l;
(vi).​ SELECT DISTINCT​ CODE​ FROM​TRAVEL;
(vii).​ SELECT A.CODE, NAME, VTYPE FROM​ TRAVEL A,VEHICLE B WHERE​
A.CODE=B.CODE​ AND​ KM<90;
(viii) SELECT​ NAME,KM*PERKM FROM​ TRAVEL A,VEHICLE B WHERE​
A.CODE=B.CODE AND A.CODE='105';
34. Write​ SQL queries for (i) to​ (iv) and find outputs for SQL​ queries​ (v) to (viii),
which are​ based on the tables.

(i) To​ display​all details from the table MEMBER in descending order of​ ISSUEDATE
(ii) To​ display​the DCODE and DTITLE of​ all Folk Type DVDs​ from the table​ DVD.
(iii) To​ display​the DTYPE and number of DVDs in​ each DTYPE​ from the table​ DVD.
(iv) To​ display​all NAME and ISSUEDATE​ of those members from the table MEMBER who​
have​ DVDs​ issued​ (i.e.,​ ISSUEDATE)​ in the year 2017)
(v) SELECT​ MIN(ISSUEDATE) FROM MEMBER;
(vi) SELECT​ DISTINCT DTYPE FROM​ DVD;
(vii) SELECT​ D.DCODE,​ NAME, DTITLE FROM DVD D, MEMBER M WHERE​
D.DCODE=M.DCODE;
(viii) SELECT DTITLE FROM DVD WHERE DTYPE NOT IN​ ("Folk","Classical");

35. Write SQL queries for (i) to (iv) and write outputs for SQL queries (v) to (viii), which are
based on the table given below :
(i) To display details of all Trains which Start from New Delhi.
(ii) To display the PNR, PNAME, GENDER and AGE of all Passengers whose AGE is below 50.
(iii) To display total number of MALE and FEMALE Passengers.
(iv) To display details of all Passengers travelling in Trains whose TNO is 12015.
(v) SELECT MAX (TRAVELDATE), MIN(TRAVELDATE) FROM PASSENGERS WHERE
GENDER = 'FEMALE';
(vi) SELECT END, COUNT(*) FROM TRAINS GROUP BY END HAVING COUNT(*)>1;
(vii) SELECT DISTINCT TRAVELDATE FROM PASSENGERS;
(viii) SELECT TNAME, PNAME FROM TRAINS T, PASSENGERS P WHERE T.TNO = P.TNO
AND AGE BETWEEN 50 AND 60;

You might also like