The close() method is used to conserve memory because: a. It closes all unused memory created by

A. The close() method is used to conserve memory because: a. It closes all unused memory created by.

A.  The close() method is used to conserve memory because: 

a. It closes all unused memory created by Python

b. It deletes all the text related to a fi le

c. It compresses a fi le

d. It removes the reference created by fi les open() function

B. If we have to open a fi le to read its content using the statement

Convert_Demo = open(‘Story.txt’,’r’)

which is a valid statement to convert each character of the fi rst line of a fi le into uppercase?

a. print(Convert_Demo[0].upper())

b. print(Convert_Demo.upper())

c. print(Convert_Demo.readline().upper())

d. All of the above

C.  If content of a fi le cities.txt is:

&Delhi&Chennai&

&Mumabi&Kolkata&Madras&

&Pune&Nagpur&Aurangabad&

What will be the output of the following code?

fp1 = open(“cities.txt”, “r”)

name = fp1.readline().strip(‘&\n’)

while name:

if name.startswith(“M”):

print(name)

else:

pass

name = fp1.readline().strip(‘&\n’)

a. &Mumbai&Kolkata&Madras& b. Mumabi&Kolkata&Madras

c. Mumabi Kolkata&Madras d. &Mumabi Kolkata Madras

D.  What is the use of ‘a’ mode in fi le handling?

a. Read              b. Write

c. Append          d. Alias

Leave a Reply

Your email address will not be published.