← All quizzes

Snake quiz

9 questions about the Python behind the game. Use the source as you go.

Python practice

Harry
Explore the source

See how the game uses grid coordinates and ordered positions. Look up answers as you go.

Python practice · Fix an upward turn

The practice snake moves down when asked to move up. Fix move() so it returns the new x and y coordinates for each direction.

This function moves one grid square. The game also checks walls, berries, and the snake’s body.

Find the game’s movement code Find the game’s cell size

Python code

Enter starts a new line with indentation. Tab moves to the next control.

Python practice · Trace a route

Predict where the head will finish. Run the route, then change one direction and run it again. Explain which coordinate changes on a vertical move.

This route starts at the game’s starting position and tracks the head’s coordinates.

Find the game’s movement code Find the starting position

Python code

Enter starts a new line with indentation. Tab moves to the next control.