Example
Output: complete Python program
print("Hello, World!")
Python Install
To run Python on your own computer, start by checking whether it is there already, since Windows or Mac machines may come with it pre-installed.
On Linux or Mac, open the terminal and type python --version.
If you don't find it, the official website offers a free download: https://www.python.org/.
On Windows, search for Python or enter the command below in the Command Line:
Check Python version
C:\Users\Your Name>python --version
Python Quickstart
Python is an interpreted language: you write your code in .py files using a text editor, and the Python interpreter runs them.
To try it, use any text editor to create and save a file named hello.py. Next, open your command line, go to the directory that holds the file, and run it.
hello.py file
print("Hello, World!")
Run hello.py
C:\Users\Your Name>python hello.py
Python Version
Importing the sys module lets you find out which version of Python is running.
Example
See which Python version the editor uses:
Output: complete Python program
import sys
print(sys.version)
The Python Command Line
For a quick test of a few lines, you can skip the file, because Python can act as a command line of its own. On Windows, Mac, or Linux, type python (or py) at the command line and start writing Python code. Type exit() once you want to leave.
Start Python command line
C:\Users\Your Name>python
Hello World in command line
>>> print("Hello, World!")
Exit command line
exit()