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

Programming Assignment II

This document is an assignment for the Introduction to Computer Programming course at Lilongwe University of Agriculture and Natural Resources, due on May 7, 2025. It consists of three questions requiring Python programming tasks, including file reading, word counting, and file copying, with specific requirements for comments and error handling. The assignment is worth a total of 10 marks and must be submitted via Google Classroom by midnight.

Uploaded by

paulsidira10
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)
3 views2 pages

Programming Assignment II

This document is an assignment for the Introduction to Computer Programming course at Lilongwe University of Agriculture and Natural Resources, due on May 7, 2025. It consists of three questions requiring Python programming tasks, including file reading, word counting, and file copying, with specific requirements for comments and error handling. The assignment is worth a total of 10 marks and must be submitted via Google Classroom by midnight.

Uploaded by

paulsidira10
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

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.

You might also like