menu

Python Input and Output


1. Which function is used to write to an Excel file in Python?

openpyxl.load_workbook()

openpyxl.read_excel()

openpyxl.write_excel()

D. openpyxl.dump_excel()


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

write()

writelines()

append()

D. None of the above


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

read()

readline()

readlines()

D. write()


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

exists()

isfile()

isdir()

D. both A and B


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

write()

read()

close()

D. open()


6. Which of the following is used to save changes to an Excel file using openpyxl?

workbook.save()

workbook.write()

workbook.update()

D. workbook.append()


7. Which function is used to read an Excel file in Python?

openpyxl.load_workbook()

openpyxl.read_excel()

openpyxl.write_excel()

D. openpyxl.dump_excel()


8. Which of the following is used to write data to a cell in an Excel sheet using openpyxl?

sheet.cell()

sheet.write()

sheet.append()

D. sheet.update()


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

write()

writelines()

append()

D. None of the above


10. Which method is used to read all the lines of a file into a list in Python?

read()

readline()

readlines()

D. write()