Course 2.3Lesson 2 of 4
The official place to get Python is python.org, on the Downloads page. On Windows, open the installer, tick the box Add python.exe to PATH on the first screen, and press Install Now. On macOS, download the installer and press Continue through the steps. On Linux, Python 3 is usually already there, and if not, install python3 and idle3 with the package manager. Check the installation by typing the version command in a terminal: py --version on Windows, python3 --version on macOS and Linux.
Try the code and the simulations beside the lesson.
After this lesson you can
The official place to get Python is python.org. Open the Downloads page. It offers the current version for your system. Do not use other websites for the installer.
What is the PATH? Your computer has a list of folders where it looks for programs when you type a command. This list is called the PATH. If the folder of Python is on the list, the terminal finds Python when you type python. If it is not, the terminal says "not recognised". The box Add python.exe to PATH puts Python on the list. It is the step that beginners forget most often.
Windows also installs the Python launcher, a small program called py. It finds your Python for you. That is why py --version often works even when python --version does not.
On macOS, the command is python3, with the number. Older versions of macOS have an old Python 2 under the plain name python, and it is not the one that you want.
Most Linux systems have Python 3 already. Open a terminal and check (see below). If it is missing, install it with your package manager. On Ubuntu and Debian:
sudo apt update
sudo apt install python3 idle3The first line refreshes the list of programs. The second one installs Python 3 and IDLE. The word sudo asks for the administrator's password. On other kinds of Linux the package manager has another name, such as dnf or pacman, but the idea is the same.
The download is the only step that needs the internet. After that, Python works offline.
Open a terminal.
cmd, and press Enter. This opens Command Prompt.Terminal, and press Enter.Type the version command and press Enter.
If you see Python 3. followed by numbers, it worked. The numbers can be different from the picture. The first one must be 3.
python --version as well as py --version.python3, not python.python opens the Microsoft Store, the PATH is not set, or a shortcut of the Store is in the way. Use py, or reinstall from python.org.Python can also be used directly in the terminal. Type python (or py, or python3) and press Enter. You see >>>. Now type 2 + 3 and press Enter. It answers 5. This is the interactive mode. It is a good place to try one small thing. To leave it, type exit() and press Enter. Later in the book, you will write whole programs as files, which is the next lesson.
>>>. The version command goes in the terminal before you start Python.python on macOS or Linux. Use python3.Start with two quick questions. Each New numbers gives you a fresh one, so you can practise as long as you like.
Then the labs and the problems:
py --version (Windows) or python3 --version (macOS and Linux).Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Every lesson is open to read. Enrolling also lets you:
Log in to join the discussion.
Loading…
This lesson is free to read. Enroll free to keep your place and take the tests.