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

A with statement closes the file automatically.

Question 2 of 10

Question 2 of 10

Explain the difference between read mode, write mode and append mode.

Question 3 of 10

Question 3 of 10

Write a program that appends a new pupil record "name,score" to results.csv and then prints all the records.

Question 4 of 10

Question 4 of 10

The block that always runs after try/except is ___.

Question 5 of 10

Question 5 of 10

int("abc") raises a

Question 6 of 10

Question 6 of 10

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

Question 7 of 10

Question 7 of 10

Which block is used to handle exceptions in Python?

Question 8 of 10

Question 8 of 10

Which method writes text to an open file?

Question 9 of 10

Question 9 of 10

An exception in Python is

Question 10 of 10

Question 10 of 10

Which statement opens a file called marks.txt for reading?

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