English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Python Basic Tutorial

Python Flow Control

Python Functions

Python Data Types

Python File Operations

Python Objects and Classes

Python Date and Time

Advanced Knowledge of Python

Python Reference Manual

Python Basics

Python is a cross-platform programming language, which means it can run on multiple platforms such as Windows, MacOS, Linux, and has even been ported to Java and .NET virtual machines. It is free and open-source.

Although most Linux and Macs are pre-installed with Python today, the version may be outdated. Therefore, installing the latest version is always a good idea.

The simplest way to run Python

The simplest way to run Python is to useThonny IDE. 

Thonny IDE comes with the bundled latest version of Python. Therefore, you do not need to install Python separately.

Please follow the steps below to run Python on your computer.

  1. DownloadThonny IDE.

  2. Run the installation program to install Thonny on your computer.

  3. Go toFile > New. Then save the file with a .py extension. For example, hello.py, example.py, etc.
    You can name the file anything you like. However, the filename should end with.pyEnd 

  4. Write Python code in the file and save it.

  5. Then go toRun > Run the current scriptOr directly clickF5to run it.

Install Python separately

If you do not want to use Thonny, please install and run Python on your computer according to the following method.

  1. DownloadThe latest version of Python.

  2. Run the installation program file and follow the steps below to install Python:
    During the installation process, selectAdding Python to the environment variablesThis will add Python to the environment variables, and you can run Python from any part of the computer.
    Additionally, you can choose the installation path for Python.

After completing the installation process, you can run Python.

1Running Python in immediate mode

After installing Python, typing 'python' in the command line will invoke the interpreter in immediate mode. We can directly input Python code and then press Enter to get the output.

Try to input,1 + 1Then press Enter. We get2As output. This prompt can be used as a calculator. To exit this mode, press Enter.

2In an integrated development environment (IDE) to run Python

We can use any text editor software to write Python script files.

We just need to save it with the .py extension. However, using an IDE can make our lives easier. An IDE is a software that provides useful features for programmers, such as code hints, syntax highlighting and checking, file browser, etc., for application development.

By the way, when you install Python, you will also install a program namedIDLEIDE. You can use it to run Python on your computer. It is a good IDE for beginners.

When you open IDLE, an interactive Python Shell will open.


Now, you can create a new file and save it as.pyextension. For example,hello.py

Write Python code in the file and save it. To run the file, go toRun > Run module  Or directly clickF5.

Your first Python program

Now that we have started and run Python, we can write our first Python program.

Let's create a very simple program named "Hello World!". "Hello, World!" is a simple program that outputs to the screen. Since it is a very simple program, it is often used to introduce a new programming language to beginners.

Type the following code in any text editor or IDE and save it as helloWorld.py

print("Hello world!")

Then, run the file. You will get the following output.

Hello world!

Congratulations! You have just written your first program in Python.

As we can see, this is very easy. This is the beauty of the Python programming language.