Skip to content

Python3 Tutorial

python3

Python 3.0, commonly known as Python 3000 or Py3k, is a major upgrade over earlier versions. To avoid carrying too much baggage, Python 3.0 was designed without backward compatibility.

Python introduction and installation tutorials are already covered in the Python 2.X tutorial, so they won’t be repeated here.

You can also check Differences between Python 2.x and 3.x to see the differences between the two.

This tutorial focuses on Python 3.x. If you are using Python 2.x, please refer to the Python 2.X tutorial.

Officially announced: Python 2 updates will end on January 1, 2020.


You can check the Python version you are using by running the following command in the command window (Windows: use Win+R to open the cmd run dialog):

python -V
or
python --version

The result of the above command is as follows:

Python 3.3.2

You can also enter Python’s interactive programming mode to check the version:

Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 

For most programming languages, the first introductory programming code is “Hello World!”. The following code uses Python to output “Hello World!”:

#!/usr/bin/python3

print("Hello, World!")

Run Example »

The common file extension for Python is .py.

You can save the above code in a hello.py file and run the script file using the python command.

$ python3 hello.py

The output of the above command is:

Hello, World!