Python3 tutorial

May 10, 2021 01:00 Python3

Table of contents

Python3 tutorial

Python version 3.0, often referred to as Python 3000, or Py3k for short. T his is a larger upgrade than earlier versions of Python. In order not to bring too much burden, Python 3.0 was not designed with down-compatibility in consideration.

View the Python version

We can use the following commands to view the Python version we use:

python -V

The above commands are executed as follows:

Python 3.8.5

You can also go into Python's interactive programming mode to view the version:

Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 202015:57:54) [MSC v.1924 64 bit (AMD64)] on win32

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


The first Python3.x program

1. For most programming languages, the first getting started programming code is "Hello World! " , the following code is to use Python to output "Hello World! ":

print("Hello, World!")
  • ​#!/usr/bin/python Specify what interpreter to run the script and where the interpreter is located, if the interpreter is not installed in /usr/bin/directory, just change it to its directory, or more generally:
    #!/usr/bin/env python ​。

2. You can save the above code and execute the script file using the python command.


3. The output of the above commands is:

Hello, World!