Menu Close

Chapter 1: Getting started with Python Language

Section 1.1: Getting Started

Python is a widely used high-level programming language for general-purpose programming, created by Guido van Rossum and first released in 1991. Python features a dynamic type system and automatic memory management and supports multiple programming paradigms, including object-oriented, imperative, functional programming, and procedural styles. It has a large and comprehensive standard library.

Two major versions of Python are currently in active use:

  • Python 3.x is the current version and is under active development.
  • Python 2.x is the legacy version and will receive only security updates until 2020. No new features will be implemented. Note that many projects still use Python 2, although migrating to Python 3 is getting easier.

You can download and install either version of Python here. See Python 3 vs. Python 2 for a comparison between them. In addition, some third-parties offer re-packaged versions of Python that add commonly used libraries and other features to ease setup for common use cases, such as math, data analysis or scientific use. See the list at the official site.

Verify if Python is installed

To confirm that Python was installed correctly, you can verify that by running the following command in your favorite terminal (If you are using Windows OS, you need to add path of python to the environment variable before using it in command prompt 🙂

$ python --version

Python 3.x Version ≥ 3.0
If you have Python 3 installed, and it is your default version (see Troubleshooting for more details) you should see something like this:

$ python --version
Python 3.9

Python 2.x Version ≤ 2.7
If you have Python 2 installed, and it is your default version (see Troubleshooting for more details) you should see something like this:

$ python --version
Python 2.7.18

If you have installed Python 3, but $ python –version outputs a Python 2 version, you also have Python 2 installed. This is often the case on MacOS, and many Linux distributions. Use $ python3 instead to explicitly use the Python 3 interpreter.

Hello, World in Python using IDLE

IDLE is a simple editor for Python, that comes bundled with Python.

How to create Hello, World program in IDLE

  • Open IDLE on your system of choice.
    • In older versions of Windows, it can be found at All Programs under the Windows menu.
    • In Windows 8+, search for IDLE or find it in the apps that are present in your system.
    • On Unix-based (including Mac) systems you can open it from the shell by typing $ idle python_file.py .
  • It will open a shell with options along the top.

In the shell, there is a prompt of three right angle brackets:

>>>

Now write the following code in the prompt:

>>> print("Hello, World")

Hit Enter ⎆ .

>>> print("Hello, World")
Hello, World