Lilongwe University of Agriculture and Natural Resources
Natural Resources College
Introduction to Computer Programming
Assignment II
Due: 7th May 2025
__________________________________________________________
Instruction:
a. This assignment has 10 marks.
b. Make sure your code has comments on every step.
c. Submit the assignment on Google Classroom by 12 mid
night.
Question 1 (3 Marks)
Write a Python program that reads a text file and displays the
following information:
Use the file written assignment_II_question_1 provided.
The total number of lines in the file.
The total number of words in the file.
The total number of characters in the file.
Question 2 (4 Marks)
Write a Python program that asks the user for a filename and a word
to search. The program should:
Open and read the file.
Count how many times the given word appears in the file (case
insensitive).
Display the line numbers where the word appears.
Handle the case where the file does not exist.
Question 3 (4 marks)
Write a Python program that copies the content of one file into
another file. The program should:
Ask the user to input the source filename and the destination
filename.
Read the content of the source file.
Write the content to the destination file.
If the source file does not exist, show an error message.