talk-data.com
People (1 result)
Activities & events
| Title & Speakers | Event |
|---|---|
|
Python Foundation Course (Session 6 of 6) - Final touches.
2025-07-07 · 17:00
Our snake eats and grows. The lesson follows these steps:
We write some functions to draw the food and to check if the the snake collides with the food. That's as far as we implement our game in the six week series. To conclude, we ask the AI assistant, in its role as an expert Python coach, to suggest ways to refactor the code and how to extend the functionality of the game We finish with a recap of what we've learnt over the six week course. This includes some final thoughts about how well the AI assistant has helped us in our coding journey, and what this implies for the sort of (human) skills needed over the next few years. Full details on the six week course here. |
Python Foundation Course (Session 6 of 6) - Final touches.
|
|
Python Foundation Course (Session 2 of 6)
2025-06-09 · 17:00
Lesson 2 focuses on conditional flow in Python - using the while, for and if-elif-else keywords. It also introduces variables, constants, datatypes, the input() and print() functions. It also covers using pygame and some of its functions and methods. We use the Python code at the end of lesson 1 as a starting point. We will create the main game loop so that our snake game can listen to events, act on some of them, and only exit when the user presses the close button on the window. In this session, we get the snake to change colour when certain keys are pressed. That introduces responding to user input. In the next session the snake will start moving! For full details about this lesson, click here. |
Python Foundation Course (Session 2 of 6)
|
|
Python Foundation Course (Session 1 of 6)
2025-06-02 · 17:00
Update: If you would like a head start, this YouTube video is a 10 minute demo of what we'll be doing in this lesson. This is a hands-on tutorial-style foundation course in Python course over six Monday evenings. It is suitable for beginners and people who have not coded before. Over the six weeks, we design and code the snake game step by step. This is an online (on Teams) course. The best way to learn Python is to write a classic game such as snake. This may seem a frivolous exercise compared to a more serious use case of, for example, data analysis. However, writing a game like this one forces us almost immediately to use many of the features of the language. We hope this will more fun and interesting than a more traditional approach, and more relevant especially to people who have not coded before. In the course, we start by creating variables and constants to set up our screen and snake. We implement our snake firstly as a single square then later as a Python data structure (a list of tuples). We use list methods, such as append and pop, to create our snake. To keep our code organised and readable, we create a Snake class so that our snake can move and eat. We use looping, (with the for and while keywords) so that the snake responds to our key presses and conditional flow (with the if keyword) so that it eats and grows when it finds food. We learn how to install and import packages such as the pygame package that provides the basic 2D game functionality. This is the first time we have run this course - expect a few bumps along the way. The provisional timetable looks like this 2nd June: Session 1 - Setup Install Python and the VSCode editor on a laptop, then create a Python environment, install some packages and write/run a tiny script to prove everything is set up properly. 9th June: Session 2 - our snake responds to user input We'll review the code in Session 1. This sets up our game and our snake is only a single square and does not move yet. We get our snake to change colours and to move up / down / left / right a single square when the user presses the arrow keys on the keyboard. This covers these Python topics: the while and for loops, invoking functions, the basic structure of a Python program. 16th June: Session 3 - move like a snake We get our snake to change colours and to move more like a snake e.g. the snake moves at a constant speed, and the arrow keys control the direction but does not allow reversing. This covers these Python topics: the if-elif-else code block, tuples, data types 23rd June: Session 4 - from a square to a snake Our snake literally takes shape and behaves more like the classic snake in the game. The game stops if the snake moves off the screen. This covers these Python topics: lists, dictionaries, writing functions. 2nd July: Session 5 - our snake eats and grows Note: this is on a Wednesday rather than Monday The snake eats food and grows when it does. This covers these Python topics: introduction to classes and object oriented programming. 7th July: Session 6 - applying the rules The game ends when the snake leaves the screen or collides with itself. If time allows we may implement a score. This covers these Python topics: more about classes, organising code into modules |
Python Foundation Course (Session 1 of 6)
|