The assignment requires students to construct a Python program that processes words and demonstrates file handling procedures. It includes tasks such as creating and reading a file, explaining file modes, and providing code examples for each mode. Additionally, students must write a program to count lines, words, and characters in a text file.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
0 views1 page
Python ASSIGNMENT-4
The assignment requires students to construct a Python program that processes words and demonstrates file handling procedures. It includes tasks such as creating and reading a file, explaining file modes, and providing code examples for each mode. Additionally, students must write a program to count lines, words, and characters in a text file.
1. Construct a program which accepts a sequence of words separated by whitespace as file
input. Print the words composed of digits only. 2. Demonstrate the file handling procedure in detail. Write a python code to create a file with ‘P.txt’ name and write your name and father’s name in this file and then read this file to print it. 3. Explain the different file modes in Python: "r": Read mode "w": Write mode "a": Append mode "r+": Read and write mode 4. Provide a Python code example that demonstrates how to open a file in each of these modes. 5. Write a Python program that reads a text file and counts the total number of lines, words, and characters in the file.