wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python L36 Snake Highscore

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

What is the purpose of with open("data.txt") as file: in the scoreboard?

a)

To print data to the screen

b)

To permanently delete the file

c)

To open and read the high score

d)

To create a new window

2.

Which method is used to update the file with the new high score?

a)

file.read()

b)

file.write()

c)

file.close()

d)

file.remove()

3.

What happens when int(file.read()) is called?

a)

It deletes the data

b)

It reads a number from the file and turns it into an integer

c)

It reads a number and converts it into a string

d)

It saves the score into the file

4.

Which of the following is true about with open(...)?

a)

It must be closed manually

b)

It reads and writes at the same time

c)

It automatically closes the file afterward

d)

It causes the game to pause

5.

In Python, the method to read the entire content of a file is (a)   ().

6.

To save the high score to data.txt, we use the mode "​ (a)   " in open("data.txt", "​ (b)   ").

Choose from the below words
write
w
a
append
r
read
7.

file.read() returns a string, even if the content is a number.

a)

True

b)

False

8.

The high score in the Snake Game is reset to 0 every time the game starts.

a)

True

b)

False

9.

What condition is checked before saving a new high score?

a)
The new score must be less than the current high score.
b)
The new score must be equal to the current high score.
c)
The new score must be greater than the current high score.
d)
The new score must be a negative number.
10.

Why do we use int() when reading the high score from the file?

a)
We use int() to store the high score as a float.
b)

We use int() to convert the string representation of the high score into an integer.

c)
We use int() to check if the high score is valid.
d)
We use int() to format the high score for display.