Skip to content
OtisamLMS
Computing

Computing · Quick practice · answer shown after each question

File handling and exceptions in Python

Question 1 of 10

Question 1 of 10

Which method reads the whole content of an open file as one string?

Question 2 of 10

Question 2 of 10

CSV files can be opened in a spreadsheet program.

Question 3 of 10

Question 3 of 10

Write a program that divides two numbers entered by the user and handles both invalid input and division by zero.

Question 4 of 10

Question 4 of 10

Data in variables is kept after the program closes.

Question 5 of 10

Question 5 of 10

Write a Python program that asks for five names and saves them, one per line, to a file called names.txt.

Question 6 of 10

Question 6 of 10

The mode used to add data to the end of a file is "___".

Question 7 of 10

Question 7 of 10

The block used to catch exceptions in Python is try ... ___.

Question 8 of 10

Question 8 of 10

int("abc") raises a

Question 9 of 10

Question 9 of 10

The mode used to open a file for reading is "___".

Question 10 of 10

Question 10 of 10

A with statement closes the file automatically.

Questions written by OtisamLMS in the style of the WASSCE. They are not WAEC past questions.