Python 3 Tutorial
Python 3 Tutorial
We’ve already covered Python’s introduction and installation tutorial in Python Environment Configuration, so we won’t repeat it here.
You can also see the differences between Python 2.x and 3.x in Differences Between Python 2.x and 3.x.
Officially announced that Python 2 updates will cease on January 1, 2020.
Checking the Python Version
We can check the Python version in the command prompt (use win+R on Windows to open the cmd run window) by running the following command:
python -V
The output 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.
>>>
First Python 3.x Program
For most programming languages, the first entry-level code is “Hello World!”. The following code prints “Hello World!” using Python:
#!/usr/bin/python3
print("Hello, World!")
You can save the above code in a file called hello.py and execute it using the python command.
$ python3 hello.py
The output of the above command is:
Hello, World!
Related content:
Python Examples
Python Functional Programming
Python Getting Started