Installing Python 3.13 and running your first script
Course contents (15 lessons)
- Getting started
- Installing Python 3.13 and running your first script
- Variables and basic data types
- Text, numbers and user input
- Working with strings
- Numbers and arithmetic
- Input and output: talking to the user
- Making decisions and repeating work
- Making decisions with if, elif and else
- Loops: for, while, break and continue
- Collections of data
- Lists and tuples
- Dictionaries and sets
- Functions and modules
- Writing your own functions
- Modules, pip and virtual environments
- Files and errors
- Reading and writing files
- Errors and exceptions
- Final project: expense tracker
- Project: build the expense tracker, part 1
- Project: summaries, search and improvements
What Python is, and why start here
Python is a general purpose programming language. People use it for automation scripts, websites, data work and machine learning. It is popular with beginners because the code reads almost like English and you can see results quickly.
In this course we use Python 3.13. Everything here also works on 3.12 and 3.14, so do not worry if your version is a little different.
Installing Python
Windows
Go to python.org, open the Downloads page and get the latest Windows installer. Run it. On the first screen there is a checkbox called Add python.exe to PATH. Tick it. This is the step people miss most often, and without it your terminal will not find Python.
macOS
Download the macOS installer from python.org and run it. If you use Homebrew, brew install python@3.13 does the same job.
Linux
Most distributions already include Python 3. Check the version first. If it is older than 3.12, install a newer one with your package manager or with a tool such as pyenv.
Check that it works
Open a terminal. On Windows that is PowerShell or Windows Terminal. Type this:
python --version
On macOS and Linux the command is often python3 --version. You should see something like Python 3.13.1. If you see "command not found", the PATH step above is the likely cause. Close the terminal and open a new one, because the old one does not see the changed settings.
The interactive prompt
Type python and press Enter. You will see >>>. This is the REPL, a place where Python runs each line as you type it. It is great for small experiments.
>>> 2 + 3
5
>>> "hello" * 3
'hellohellohello'
>>> exit()
I still use the REPL every day to check a small idea before I put it in a real file.
Your first script
The REPL forgets everything when you close it. Real programs live in files. Make a folder called python-course, open it in any text editor (VS Code is a good free choice) and create a file named hello.py.
# hello.py
name = "Ghulam"
print("Hello, " + name + "!")
print("Python is working.")
Save the file. In the terminal, go to the folder and run it:
cd python-course
python hello.py
The output is:
Hello, Ghulam!
Python is working.
What the script does
The first line starts with #. That is a comment. Python ignores it, and it is there for humans. The second line creates a variable called name and stores the text "Ghulam" in it. We will cover variables in the next lesson. The print function shows text on the screen. The + joins two pieces of text together.
Python runs a file from the top to the bottom, one line at a time. That simple rule explains a lot of behaviour you will see later.
Common mistakes
- Saving the file as hello.py.txt. Windows hides known extensions by default. Turn on "File name extensions" in Explorer and check.
- Running the command inside the REPL. If you see
>>>and typepython hello.py, you get a syntax error. Typeexit()first. - Being in the wrong folder. The error "can't open file" nearly always means your terminal is in a different directory from your script.
- Mixing up quotes.
"hello"and'hello'both work. Starting with one kind and ending with the other does not.
Reading an error message
You will see errors often. That is normal, and I still get them every day. Python prints the file name, the line number and a description. Always read the last line first. It tells you what went wrong, such as SyntaxError or NameError. Then look at the line number it points to.
Try it yourself
Create a file called about_me.py. Use three print calls to show your name, your city and one thing you want to build with Python. Run it from the terminal. Then change one of the lines on purpose to remove a closing quote, run it again, and read the error message.
# hello.py
name = "Ghulam"
print("Hello, " + name + "!")
print("Python is working.")
This course is free to read. Create a free account to enrol, save your progress and pick up where you left off.
Sign up free I already have an account