Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
29 views

Python programs for practical exam

Practical qns for computer science examination
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Python programs for practical exam

Practical qns for computer science examination
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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 “Source.txt” to another text file called “Destination.txt”.
1 8
(Create the “Source.txt” in Notepad and write data to the file using notepad editor)
• Function to count and print the total number of vowels in the file “Source.txt”

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 “countries.csv”. 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 “countries.csv”
A binary file “Book.dat” 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 Book.dat .
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 “Book.dat

5 Write a program to perform the operations (push, pop and display) on a stack of integers in 8
python. LIST PROGRAM
The “Products.csv” file has the following header ['PID','PNAME','COST', ‘QUANTITY’].
6 Write a function to add the records in the “Products.csv” 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 “student.dat” 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 “Students.dat”.
8 8
Write a function countrec( ) that would read the contents of file “Students.dat” 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 “Train.csv” file has the following header ['TID','TNAME',’SOURCE’,


‘DESTINATION’].
10 Write a function to add the records in the “Train.csv” file. 8
Write a function to accept a particular Train Id from the user and display the details of that
particular train.

Page 1

You might also like