Practical File Questions
Instructions
Read the instructions carefully before starting.
Write the heading with program as: eg given below
Program 1
Write a program that reads a string and prints whether it’s a palindrome or not
Sol: write the code…
Input and output to be shown on the left side (blank side) and written in pen
only.
Program to be written on right side ruled area.
If program code is small then only two programs per page.
But output has to be shown for every program on the left side.
Indentation should be well defined and showed
No cutting/striking. Avoid errors. Be sure of the answer before you fair it in the
file
Index to be maintained with proper dates , program no ,program details, page
no
Dates have been specified against each program. Write only those dates
Don’t tear the pages or overwrite. It should be neat.
Record file to be neatly covered with brown paper and name written inside
1. Write a program that reads a string and prints whether it’s a palindrome or not
( 7/4/24)
2. Write a program to input a string and print the no of characters, words and digits in it.
(7/4/24)
3. Write a program to input 10 integers using a list and sort them using (i) bubble sort
(ii) insertion sort(18/4/24)
4. Write a program to have the following functions: (a) a function cube() that takes a
number as argument and calculates the cube of it. The function does not return a
value. If there is no value passed to the function, the function should calculate the
cube of 2
(b) a function that takes two char arguments and returns True if both arguments are
equal otherwise false. (21/04/24)
5. Write a program that calls a function onescompare() which takes two numbers as
parameters and returns the number that has maximum ones digit.(21/04/24)
6. Write a program that generates a series using a function AP() which takes the first and
last values of the series and then generates four terms that are equidistant. Eg if two
nos passed are 1 & 7, then function returns 1,3,5,7 (24/04/24)
7. Write a function that receives two numbers and generates a random number from that
range. Using this function, the main program should be able to print three numbers
randomly.(24/4/24)
8. Write a menu program to perform the following operations on simple data structure
list where the list is sorted. (1) add an elt at its proper position (2) traverse the list
and print them on separate lines(3) delete an elt from the list (4) merge two list (5)
exit from program
9. Write a program to count the words ‘to’ and ‘the’ present in a text file
“Poem.txt”(07/05/24)
10. Write a function countVowel() in Python, which should read each character of a text
file “myfile.txt” and then count and display the count of occurrence of vowels
(including small cases(07/05/24)
11.Write a program that reads characters from a file. All lowercase characters
get stored in the file “Lower.txt”, all uppercase case characters get stored
in “Upper.txt” and all other characters gets stored in
file“Others.txt”(08/05/24)
12.Write a function Lines() to count and display the number of lines starting
with ‘T’ from a text file “Lines.txt” (10/05/24)
13.Write a program to read a text file line by line and display each word
separated by a ‘#’(12/05/24)
14.Write a program to display all the lines that contain the character ‘n’ in a
text file ‘source.txt’ and write that line to another file ‘target.txt’ .
(20/05/24)
15.Write a program that contains two functions called
(i) createfile() that adds 5 records with structure
[bookno,bookname,author,price] in the binary file book.dat.
(ii) countrec(author) that counts the no of books written by the specified
author and also display the book details.(25/05/24)
16.Write a program to write a menu based program with student structure
being a dictionary with keys as rollno , name and marks using a binary
file ‘stu.dat’. The following operation should be performed using function
definitions Adding records, Display all records, Search Record according
to rollno, Update record with modified marks .(28/05/2)
17. Write a program to create a csv file ‘emp.csv’ with the structure
[empno,empname,salary] that has two function definitions
(i) empcreate() that writes 5 records into it.
(ii) empdisplay() that displays all the records stored in the csv file
(31/05/22)
18.Write a menu based program to create the stack operations
push,peek,display and pop where the elt is a node containing
member_no,name,age in the form of a list (07/06/24)
19. A list contains following record of a
customer: [Customer_name, Phone_number,
City] (10/06/26)
Write the following user defined functions to perform given operations
on the stack named ‘status’:
(i) Push_element() - To Push an object containing name and
Phone number of customers who live in Goa to the stack
(ii) Pop_element() - To Pop the objects from the stack and display
them. Also, display “Stack Empty” when there are no elements
in the stack.
For example:
If the lists of customer details are:
[“Gurdas”, “99999999999”,”Goa”]
[“Julee”, “8888888888”,”Mumbai”]
[“Murugan”,”77777777777”,”Cochin”]
[“Ashmit”, “1010101010”,”Goa”]
The stack should contain [“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
The output should be:
[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
Stack Empty
20. Write a query to (18/06/24)
(i)create a student table with foll details
Ad_No primary key not null, St_Name varchar(20), Address varchar(40),
Gender char(1), DOB date, DOA date
ii) Alter table to add new column phone varchar(10)
iii) Add 5 records in it.
iv) Update a record to change the phone no of a student
v) Delete a record
vi) write query to order the records according to ascending order of
names
21. Consider the following table and write the queries and
output (25/06/24)
i. To display all the items in the ascending order of LastBuy
ii. To display itemno and item name whose rate is above 15 rs
iii. To display the details of those items where supplier code is 22 or qty in store is more
than 110
iv. Select total amt (calculated as rate* qty) where itemno is 2002,2004 and 2006
v. Increase the rate by 20 rs where supplier code is 22
vi. To display all the item names where the 3rd letter is ‘a’
vii. Display all the details where lastbuy is in Feb month2010
viii. Display item name, qty and rate where rate is between 15 and 25
ix. Write the outputs for the following queries
(a) select item, scode from store where scode in(21,23);
(b) select item from store where item like ‘%i_’;
(c) select itemno, itemname from store where where qty >= 150 and lastbuy like
‘2009-03%’;
22. Do the questions given in the given table (02/07/24)
23.Write the sql queries for the given table (10/07/24)
24.Write a program using data base connectivity and access and print all
records from emp table of the employee database (05/08/24)
Where emp table has fields empno,empname, DOJ, Salary,Department
25. Create a python mysql interface to connect to a database named LIBRARYwith a table
named Books with fields book_code,book_name,author,price. (16/08/24)
Create a menu based program to
(1) Add or insert records in the table
(2) Modify the price based on book_code
(3) Delete a record based on book_code
(4) Display all the records
(5) Search and display a record based on book_code
(6) Exit the program