Sr.
Task Marks
Write a Python program with the following user defined functions:
• Function to write those lines which have the character 't' from one text
file “[Link]” to another text file called “[Link]”.
1 8
(Create the “[Link]” in Notepad and write data to the file using notepad editor)
• Function to count and print the total number of vowels in the file “[Link]”
Write a menu-based Python program to do the following:
2 a) To test if a string entered by the user, is a palindrome or not. 8
b) To print the factorial of number. The number is accepted from the user.
Write a program to add the following header in a csv file ['COUNTRY', 'CAPITAL', 'CODE']
called “[Link]”. Write a function to accept data from the user and write to the file till
3 the user wishes to continue. 8
Write a function to display the details from the csv file “[Link]”
A binary file “[Link]” has structure [BookNo, Book_Name, Author, Price].
a) Write a user defined function CreateFile( ) which will accept data for a record from the
user and add details to [Link] .
4 8
b) Write a function CountRec(Author) in Python which accepts the Author name as
parameter. The function counts and returns the number of books by the given Author
stored in the binary file “[Link]
5 Write a program to perform the operations (push, pop and display) on a stack of integers in 8
python. LIST PROGRAM
The “[Link]” file has the following header ['PID','PNAME','COST', ‘QUANTITY’].
6 Write a function to add the records in the “[Link]” file. 8
Write a function to display the total quantity of all the products in the csv file.
Write a Python program that creates a binary file containing the student’s roll number, name
and percentage.
7 The insert function (user defined function) should accept values from the user and write the 8
information (list) in the binary file.
The display function should print all the records from the binary file.
A binary file “[Link]” has structure [Admission_number, Name, percentage].
Write a function AddDetails( ) that will accept details of the student from the user and add it
to the binary file “[Link]”.
8 8
Write a function countrec( ) that would read the contents of file “[Link]” and display
the details of those students whose percentage is above 75.
Also display number of students scoring above 75%
Write a menu driven Python program to perform the following:
i. Linear search
9 ii. Display the list in reverse order 8
iii. Display all the numbers ending with the number 2
The “[Link]” file has the following header ['TID','TNAME',’SOURCE’,
‘DESTINATION’].
10 Write a function to add the records in the “[Link]” file. 8
Write a function to accept a particular Train Id from the user and display the details of that
particular train.
Page 1