5 Lab Evaluation - File IO

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

File Handling

1. File Ascending Order


Consider an input file, "numbers.txt" with integer values. Write a program to Open the file
and sort the content of the file in ascending order.
Note: The file name should be numbers.txt.
2. Write a program to copy the content from one file to another file.
Rules:
The input file should be named "input.txt".
The output file should be named "output.txt".
3. Sum of the Integers in the file
Consider an input file "numbers.txt" with integer values. Write a program to Open the
file and read the content to find the sum of all values in the file.
Note: The file name should be numbers.txt.
4. Write a python program to read the content from a text file "mbox.txt" line by line and
display the same on-screen.
5. Write a program in Python to read lines from a text file "notes.txt". Your function should
find and display the occurrence of the word "the". For example: If the conte nt of the file is:
"India is the fastest-growing economy. India is looking for more investments around the
globe. The whole world is looking at India as a great market. Most of the Indians can foresee
the heights that India is capable of reaching."
The output should be 5.
*******************

You might also like