Font size
WorksheetsPython L36 Snake Highscore
Total questions: 10
Worksheet time: 6mins
What is the purpose of with open("data.txt") as file: in the scoreboard?
To print data to the screen
To permanently delete the file
To open and read the high score
To create a new window
Which method is used to update the file with the new high score?
file.read()
file.write()
file.close()
file.remove()
What happens when int(file.read()) is called?
It deletes the data
It reads a number from the file and turns it into an integer
It reads a number and converts it into a string
It saves the score into the file
Which of the following is true about with open(...)?
It must be closed manually
It reads and writes at the same time
It automatically closes the file afterward
It causes the game to pause
In Python, the method to read the entire content of a file is (a) ().
To save the high score to data.txt, we use the mode " (a) " in open("data.txt", " (b) ").
file.read() returns a string, even if the content is a number.
True
False
The high score in the Snake Game is reset to 0 every time the game starts.
True
False
What condition is checked before saving a new high score?
Why do we use int() when reading the high score from the file?
We use int() to convert the string representation of the high score into an integer.
