Python3 Tutorial Introduction


The 3.0 version of Python is often referred to as Python 3000, or Py3k for short. Compared to earlier versions of Python, this is a major upgrade. In order not to bring too much cumbersomeness, Python 3.0 was not designed for backward compatibility.

Python introduction and installation tutorial We will be introducing it in this tutorial.

This tutorial is mainly for learning the Python 3.x version. If you are using the Python 2.x version, please move to the Python 2.x version of the tutorial.

Important: It is officially announced that on January 1, 2020, the update of Python 2 will be discontinued.


Check Python version

We can use the following command to check the Python version we are using in the command window (Windows uses win+R to call up the cmd run box):

python -V
OR
python --version

The execution result of the above command is as follows:

Python 3.8.10

You can also enter the interactive programming mode of Python and check the version:

Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>>


The first Python 3.x program

For most programming languages, the first introductory programming code is "Hello World!", the following code uses Python to output "Hello World!":

Example (Python 3.0+)

#!/usr/bin/python3
 
print("Hello, World!")


You can save the above code in the hello.py file and use the python command to execute the script file.

$ python3 hello.py

The output of the above command is:

Hello, World!