WS TXT Ii
WS TXT Ii
1. Write a program to write three lines of text to a file ‘abc.txt’ using writelines() method.
2. Write a program to calculate the sum of two numbers entered by the user and write the result to
a file named ‘result.txt’.
3. What is the advantage of using ‘with’ statement along with open function?
5. Write a program to append data to file ‘abc.txt’. Also read the final contents of the file and display them.
8. Write a user defined function countP() in Python that displays the number of lines starting with ‘P’
in a file ‘Para.txt’.
10. Write a function Func1() in Python to write multiple lines of text to a file ‘myfile.txt till the user wishes to continue.
Also, display the total number of lines written by the user.(Hint: use write() method)