Practical File Questions
Practical File Questions
1 Write a menu driven program to accept a string from the user and perform the following on it
using functions:
• Reverse
• replace ‘s’ or ‘S’ with “#”
• Find the repeating characters in the string
• Encode the string by adding 2 to each ASCII value
2 Write a program to create a dictionary containing names of books as keys and authors as
values.
3 Write a program that receives two numbers in a function and returns the results of all
arithmetic operations on these numbers
4 Write a function in Python to find and display the prime numbers between 2 to N. Pass N as
an argument to the function..
5 Write a function fiveEnding(SCORES) to add all those values in the list of SCORES,which are
ending with five(5) and display the sum.
6 Assuming that a text file named practical.txt contains some text written into it, write a function
that reads the file practical.txt and creates a new file named response.txt, to contain only those
words from the file practical.txt which have 5 characters. For example if the file practical.txt
contains Carry umbrella and overcoat when it rains Then the file response.txt shall contain
Carry rains
7 Write a menu driven program to add, and display data from a text file. The text file contains
bank details (Account number, name and balance).
8 Write a menu-driven program, to create a Phonebook Directory(Phonebook.txt) using different
functions. The functions have to created for the following features of the Phonebook Directory: •
Storing the Contact Numbers of People • Searching for the Contact Number using the person's
name • Displaying the data in the Directory • Updating the persons Contact number using the
person’s name
9 A binary file "Book.dat" has structure [BookNo, Book_Name, Author, Price]. • Write a user
defined function createFile() to input data for a record and add to Book.dat. • 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". • Write a function
deldata() to delete the record from the file for the BookNo entered by the user.
10 A csv file Students.csv has the structure[rollno,name,marks]. • Write a user defined function
addrecord() to input data for a record and add to Students.csv. • Write a function modifyrecord()
in Python which accepts the roll numbe rand then modifies the record. • Write a function
deleterecord() in Python which accepts the roll number and then deletes the record if the roll
number exists in the file. • Write a function search() in Python which accepts the roll number and
then displays the record if the roll number exists in the file. • Write a function viewall() in Python
which accepts the roll number and then displays the record if the roll number exists in the file.
11 . Write a program to show all the tables that exist in MySQL using Python Interface
12 Write a program to check for all the databases, present in MySQL using Python.
13 Write a program to insert multiple records onto mysql table Employee using Python and also
display all the records present in the table.
14 Create a menu driven application with options add modify delete and display data from
MySQL table Customer with fields accno, name, balance, mobno and emailed.
15 Write a python program to maintain book details like book code, book title and price using
stacks data structures. Implement push(), pop() and traverse() functions.
16 Write a menu based program to add, delete and display the record of hostel using list as
stack data structure in python. Record of hostel contains the fields : Hostel number, Total
Students and Total Rooms.
17 Write a function in Python PUSH(Arr), where Arr is a list of numbers. From this list push all
numbers divisible by 5 into a stack implemented by using a list. Display the stack if it has at
least one element, otherwise display appropriate error message.
18 Write a function in Python POP(Arr), where Arr is a stack implemented by a list of numbers.
The function returns the value deleted from the stack