Monthly Test Class XII CS May June
Monthly Test Class XII CS May June
1. Python statement can be used to print second last line of a text file "Myfile.txt"?
2. Consider following Python Code to read text file:
F=open(“Story.txt”)
Data=F.read(10).
print(type(Data),len(Data))
3.
4. Write a function to read a text file “Arhieve.txt” and display only those lines which have
10 or more words.
5. (a) What will be the result of execution of python statement f.seek(0), if f is a file object
for a text file?
a. Current file pointer/cursor position will be printed
b. The cursor will be placed at the end of the file
c. The cursor will be placed at the beginning of file
d. The cursor will be placed at the beginning of the current line
(b) A text file is opened using the statement f = open(‘story.txt’). The file has a total of 10
lines. Which of the following options will be true if statement 1 and statement 2 are
executed in order. Statement 1: L1 = f.readline( )
Statement 2: L2 = f.readlines( )
a. L1 will be a list with one element and L2 will be list with 9 elements.
b. L1 will be a string and L2 will be a list with 10 elements.
c. L1 will be a string and L2 will be a list with 9 elements.
d. L1 will be a list with 10 elements and L2 will be an empty list
Monthly Test Class XII Computer Science May-June 2022
Q1.
Q2. Write python statement to open a file “Examination.txt” in append mode .The file is stored
in D drive.
Q3. Write python statement to put pointer of file mentioned in question one at the beginning of
file.
Q4. What will be python statement to display total no. of bytes of file mentioned in question 1.
Q5. Write python function to convert all lower case letters of a file “School.txt” in upper case
letter and display final result.
Monthly Test Class XII Computer Science May-June 2022
2.
fin=open(“student.txt”)
rec=fin.readline()
while rec :
rec=fin.readline()
print(rec , len(rec))
fin.close()
Q5. Write python statement to read of file after 10th byte from the beginning and display
the content.
Monthly Test Class XII Computer Science May-June 2022
1. Write a user defined function to copy the total number of words of length 5 or
more present in the file.Quotes.txt into another file “5orMore.txt”.
2.
3. What will be python statement to read 12 characters from a file using the file
object ?
4.
5.
WAF in python to read a text file “paragraph.txt , read this file and copy all those
lines which are starting with A , An and The in to another file “Article.txt”.
E. 1.
Monthly Test Class XII Computer Science May-June 2022
1.
2.
3.
5.
F. 1.
Monthly Test Class XII Computer Science May-June 2022
2.
3.
4.
5.