menu

Python Input and Output


1. Which module is used to work with CSV files in Python?

csv

os

sys

D. io


2. Which function is used to open a CSV file in Python?

csv.reader()

csv.writer()

csv.open()

D. csv.read()


3. Which method is used to check if a file exists in Python?

exists()

isfile()

isdir()

D. both A and B


4. Which of the following is used to write data to a file in Python?

write()

read()

close()

D. open()


5. Which of the following is used to read a binary file in Python?

'rb'

'wb'

'ab'

'xb'


6. Which of the following is used to close a file in Python?

close()

write()

read()

D. open()


7. Which function is used to create a directory in Python?

os.mkdir()

os.chdir()

os.getcwd()

D. os.listdir()


8. Which of the following modes is used to read a file in Python?

'w'

'r'

'a'

'x'


9. Which method is used to read a single line from a file in Python?

read()

readline()

readlines()

D. write()


10. Which function is used to display output in Python?

input()

display()

print()

D. show()