← All quizzes
Head position after each move
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 sizePython code
Enter starts a new line with indentation. Tab moves to the next control.
Output
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 positionPython code
Enter starts a new line with indentation. Tab moves to the next control.
Output
Coordinate (px)Move
- x position
- y position
View data table
| Move | x position | y position |
|---|