talk-data.com talk-data.com

Event

Python Foundation Course (Session 4 of 6) - Writing Functions

2025-06-23 – 2025-06-23 Meetup Visit website ↗

Activities tracked

7

Our snake moves at a constant speed, and cannot turn back on itself like the classic snake in the game. The game stops if the snake moves off the screen.

This covers these Python topics: writing functions and refactoring code. We start preparing to make the snake into a class rather than a list.

This is the agenda:

  • a recap and explanation of the current code (as a reminder and a brief introduction for anybody joining the course for the first time)
  • a short lesson to introduce writing functions
  • improve the geometry to think of the snake as moving over squares on a board, rather than pixels. This makes the subsequent tasks easier.
  • make our snake move at constant speed in the direction of the latest arrow key pressed.
  • restrict the snake’s movement so that it cannot double-back on itself
  • check if the snake has moved off the screen and end the game if so
  • refactor the code and write a few functions: for example, to draw the snake, and to change the snake's direction

Full details on the six week course here.

Sessions & talks

Showing 1–7 of 7 · Newest first

Search within this event →

A short lesson to introduce writing functions

2025-06-23
talk

a short lesson to introduce writing functions

Check if the snake has moved off the screen and end the game if so

2025-06-23
talk

check if the snake has moved off the screen and end the game if so

Improve the geometry to think of the snake as moving over squares on a board, rather than pixels

2025-06-23
talk

improve the geometry to think of the snake as moving over squares on a board, rather than pixels. This makes the subsequent tasks easier.

Make our snake move at constant speed in the direction of the latest arrow key pressed

2025-06-23
talk

make our snake move at constant speed in the direction of the latest arrow key pressed.

Recap and explanation of the current code

2025-06-23
talk

a recap and explanation of the current code (as a reminder and a brief introduction for anybody joining the course for the first time)

Refactor the code and write a few functions: for example, to draw the snake, and to change the snake's direction

2025-06-23
talk

refactor the code and write a few functions: for example, to draw the snake, and to change the snake's direction

Restrict the snake's movement so that it cannot double-back on itself

2025-06-23
talk

restrict the snake’s movement so that it cannot double-back on itself