Data and AI Training

Home | Prices | Contact Us | Courses: Power BI - Excel - Python - SQL - Generative AI - Visualising Data - Analysing Data

Python Snake Course Lesson 1 - Install Python, VSCode and configure environment

Back to Python Snake Course Landing Page

Thanks for signing up to session 1 of the Python Course. We have a lot of sign-ups so we may repeat this session on Wednesday if need be.

As a reminder, in this first session we will install Python and VSCode (our editor) locally on our computer and set up a basic Python script. This course does need a local installation of Python. A remote installation such as Google Colab or GitHub Codespaces will not work. In some respects this is the toughest session of the course! We get started with coding in Python properly in the next session.

It’s worth having a read of our guide to how we build the snake game. This takes about 5 minutes and it has some useful information and tips.

Here is a YouTube video that demos all the instructions. It is 10 minutes long.

Here are the instructions that we will go through during the session.

Download Python from https://www.python.org/downloads/ and install on your PC/Mac.

Download VSCode from https://code.visualstudio.com/download and install on your PC/Mac.

Launch VSCode then:

  1. create a new project and folder
  2. install the Python extension,

We can then write a one-line Python “hello world” script that confirms that everything is set up correctly so far.

  1. Create a new file named “hello.py”
  2. Add a single line print("hello world")
  3. Save the file
  4. Open a terminal window and enter “py hello.py” to run the script. You should see “hello world” output in the line below.

Next we create a virtual environment for our project This is a local subfolder containing the Python executables, where we can safely install packages without affecting our main Python installation).

  1. Create a new .venv virtual environment for this project

Next we install the pygame package into it. The pygame package contains some basic functionality to create window and draw our snake.

  1. create a terminal window
  2. in the terminal window, type pip install pygame

Next, we will create a new Python script and copy/paste some existing Python code into it, then run it. This will check that Pygame has been installed correctly.

  1. Create a new file named snake_game.py
  2. Copy the contents of this Python file into snake_game.py.
  3. Save snake_game.py.
  4. In the terminal window, type py snake_game.py. This should open a window, similar to the screenshot below, for a couple of seconds.

pygame check window

Congratulations! You are now ready to join session 2 next week when we start coding in Python properly.