0% found this document useful (0 votes)
120 views2 pages

Practice Questions

baby

Uploaded by

nityam3109.2018
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)
120 views2 pages

Practice Questions

baby

Uploaded by

nityam3109.2018
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/ 2

1.Write a user defined function in Python to read the content from a text fileMYbook.

txt, count
and display the number of blank spaces present in it.
2.Write a function in Python to count the number of alphabets present in atext file
“NOTES.TXT”.
3.Write a function in Python to count and display the number of words startingwith a vowel
present in a given text file “ABC.TXT”.
4.Write a function which reads an already existing file “text1.txt” and writedigits (0-9) in to a new
text file “DIGIT.TXT” and non digit files into NONDIG.TXT.
5.Write a function in Python to count the number of lines present in a text file“STORY.TXT”.
6.Assuming that a text file named TEXT1.TXT already contains some textwritten into it. Write a
function named vowelwords(), that reads the file TEXT1.TXT and creates a new file named
TEXT2.TXT , which shall containonly those words from the file TEXT1.TXT which don’t start
with an uppercase vowel.
7.Write a program that displays the size of a text file in bytes.
8. Write a function in Python to print the count of the word is as an independent word in a text
file DIALOGUE.TXT.For example , if the content of the file is This is his book. Is this book good?
9.Write an interactive Python program to read a text file and display the following :
(i) Frequency table of all the alphabetic characters
(ii)Number of numeric characters present in the file

10. 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" Solution

11. A binary file "STUDENT.DAT" has structure (admission_number, Name, Percentage). Write
a function count_rec() 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 number of
students scoring above 75% Solution

12. Given a binary file employee.dat, created using dictionary object having keys: (empcode,
name, and salary)

Write a python function that add one more record at the end of file.
Write a python function that display all employee records whose salary is more that 30000
Solution
13. Write a function to search and display details of student whose rollno is '1005' from the
binary file student.dat having structure [rollno, name, class and fees]. Solution

14. A binary file school.dat has structure(rollno, name, class, fees)

Write a definition for function total_fees( ) that reads each object of file and calculate the total
fees of students and display the same. Solution
15. A binary file players.dat, containing records of following list format: [code, name, country and
total runs]

17. Write a python function that display all records where player name starts from 'A'
18. Write a python function that accepts a country as an argument and count and display the
number of players of that country.
19. Write a python function that adds one record at the end of file.
20. Given a binary file game.dat, containing records of following list format: [game_name,
participants]
21. Write a function in Python that would read contents from the file game.dat and creates a file
named basket.dat copying only those records from game.dat where the game name is "Basket
Ball" Solution

You might also like