Class 12 : File Handling Set 4

11. what will be the output of the following code?

fh=open("poem.txt","r")
	s1=fh.readline()
	s2=fh.readline()	
	s3=fh.read(15)
	print(s3)
	fh.close()

12.
Write a program to copy the contents of the file ‘poem.txt’ to ‘poem1.txt’ barring the lines starting with letter ‘b’.

13.
Write a code to print just the last line of the file ‘poem.txt’.

14.
Write a single loop to display all the contents of file poem.txt after removing leading and trailing whitespaces.

15.
A text file contains alphanumeric text say an.txt. write a program that reads this text file and prints only the numbers or digits from the file.