Skip to content

How to Get Started With Python?

  • by
python

In this tutorial, you will learn to install and run Python on your computer. Once we do that, we will also write our first Python program.

Python Install

Many PCs and Macs will have python already installed.

To check if you have python installed on a Windows PC, search in the start bar for Python or run the following on the Command Line (cmd.exe):

C:\Users\Your Name>python --version

To check if you have python installed on a Linux or Mac, then on linux open the command line or on Mac open the Terminal and type:

python --version

If you find that you do not have python installed on your computer, then you can download it for free from the following website: https://www.python.org/

Python Quickstart

Python is an interpreted programming language, this means that as a developer you write Python (.py) files in a text editor and then put those files into the python interpreter to be executed.

The way to run a python file is like this on the command line:

C:\Users\Your Name>python helloworld.py

Where “helloworld.py” is the name of your python file.

Let’s write our first Python file, called helloworld.py, which can be done in any text editor.

//helloworld.py

print("Hello, World!")

The Easiest Way to Run Python

The easiest way to run Python is by using Thonny IDE.

The Thonny IDE comes with the latest version of Python bundled in it. So you don’t have to install Python separately.

Follow the following steps to run Python on your computer.

  1. Download Thonny IDE.
  2. Run the installer to install Thonny on your computer.
  3. Go to File > New. Then save the file with .py extension.
    For example, hello.py, example.py etc. You can give any name to the file. However, the file name should end with .py
  4. Write Python code in the file and save it.
python-run

Then Go to Run > Run current script or simply click F5 to run it.

The Python Command Line

To test a short amount of code in python sometimes it is quickest and easiest not to write the code in a file. This is made possible because Python can be run as a command line itself.

Type the following on the Windows, Mac or Linux command line:

C:\Users\Your Name>python

From there you can write any python, including our hello world example from earlier in the tutorial:

C:\Users\Your Name>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello, World!")

Which will write “Hello, World!” in the command line:

C:\Users\Your Name>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello, World!")
Hello, World!

Whenever you are done in the python command line, you can simply type the following to quit the python command line interface:

exit()

Leave a Reply

Your email address will not be published. Required fields are marked *