You are on page 1of 1

MCA42 – Handout-9

Topic –Files

1. Develop a script that will prompt the user for a file name, then print all lines from the file that
contain the Python comment character #.

2. Develop a script that will prompt the user for a file name, read all the lines from the file into
a list, sort the list, then print the lines in sorted order.

3. Develop a script that asks the user for a file name, then prints the number of characters, words
and lines in the file.

4. Develop a script that asks the user for a file name, then prints the number of occurrences of
each word in the file.

5. Develop a python script that will prompt the user for a string and a file name, and then print all
lines in the file that contains the string entered by the user.

You might also like