menu

Python Input and Output


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

input()

display()

print()

D. show()


2. Which function is used to remove a directory in Python?

os.rmdir()

os.remove()

os.rename()

D. os.mkdir()


3. Which function is used to write to a PDF file in Python?

PyPDF2.write()

PyPDF2.save()

PyPDF2.add()

D. PyPDF2.append()


4. Which function is used to read a PDF file in Python?

PyPDF2.read()

PyPDF2.load()

PyPDF2.open()

D. PyPDF2.extract()


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

'rb'

'wb'

'ab'

'xb'


6. Which function is used to remove a file in Python?

os.remove()

os.rename()

os.mkdir()

D. os.rmdir()


7. Which of the following modes is used to append data to a file in Python?

'r'

'w'

'a'

'x'


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

read()

readline()

readlines()

D. write()


9. Which function is used to read a JSON file in Python?

json.read()

json.load()

json.write()

D. json.dump()


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

os.mkdir()

os.chdir()

os.getcwd()

D. os.listdir()