Free preview
Installing Python and VS Code
Practical task · 20 min
Before writing programs you need two free tools: Python itself and a code editor. We use Visual Studio Code because it's free, works on every system and has an excellent Python extension.
- 1
Install Python
Go to python.org, open Downloads and install the latest Python 3 for your system. On Windows, tick "Add python.exe to PATH" on the first screen of the installer. This one checkbox prevents the most common beginner problem.
- 2
Check it worked
Open a terminal (Windows: search for "Terminal" or "Command Prompt"; macOS: Terminal). Type
python --versionon Windows orpython3 --versionon macOS and Linux. You should see something likePython 3.13.1. - 3
Install VS Code
Download it from code.visualstudio.com and install it.
- 4
Add the Python extension
In VS Code, open the Extensions panel (the four squares on the left), search for "Python" and install the one published by Microsoft.
- 5
Make a project folder
Create a folder called
python-courseand open it in VS Code with File → Open Folder.
Your first program
Create a file called hello.py and type:
print("Hello, world!")
print("Python is working.")Click the ▷ Run button at the top right, or open the terminal inside VS Code (View → Terminal) and type:
python hello.py(Use python3 on macOS and Linux.) The output appears in the terminal.
The interactive shell
Type python (or python3) on its own in a terminal and you get the >>> prompt. You can type any Python line and see the result immediately, which is perfect for quick experiments:
>>> 7 * 6
42
>>> "ha" * 3
'hahaha'
>>> exit()Getting input
name = input("What's your name? ")
print(f"Nice to meet you, {name}!")input() pauses the program, waits for the person to type something and press Enter, and gives you what they typed as a string.
Try it
Personal greeting
Write greet.py that asks for a name and a favourite food, then prints one sentence using both. Run it twice with different answers.
Show a worked answer
name = input("Your name: ")
food = input("Favourite food: ")
print(f"{name}, I hear {food} is your favourite. Good choice!")Like this lesson?
Python Programming has 20 lessons with exercises, quizzes and a final project.