Skip to content
FLAVIO COPES
flaviocopes.com

Introduction to Python

By

An introduction to Python, the interpreted, dynamically typed language created by Guido van Rossum that powers web development, automation, data, and ML.

~~~

Python is a general-purpose programming language known for its clear syntax.

You can use it for automation, Web development, data analysis, machine learning, command-line tools, and many other kinds of programs.

It is also a great first programming language. You can focus on learning how to solve a problem without fighting a lot of syntax.

This is a complete Python program:

name = 'Flavio'
print(f'Hello {name}')

Save it in a file called hello.py, then run:

python3 hello.py

What kind of language is Python?

Python is a high-level, interpreted language.

You write source code and run it with a Python interpreter. The exact details depend on the implementation you use, but you normally do not have a separate compile step before running a program.

Python is also dynamically typed. Values have types, but a variable name is not permanently tied to one type:

value = 20
value = 'twenty'

This makes it quick to write programs. It also means that some mistakes are found only when the affected code runs.

You can add type hints when they make a program easier to understand:

def greet(name: str) -> str:
    return f'Hello {name}'

Type hints do not turn Python into a statically typed language. Python itself does not enforce them at runtime, but editors and type-checking tools can use them to find problems earlier.

Python supports procedural, object-oriented, and functional programming styles. You do not need to pick one before starting.

The official Python FAQ has a good short description of the language.

The standard library and third-party packages

Python comes with a large standard library.

It includes modules for working with files, dates, JSON, databases, HTTP, testing, and much more.

When the standard library does not have what you need, you can install packages from the Python Package Index, usually called PyPI.

This combination is one of Python’s biggest strengths: a useful standard library and a huge ecosystem of packages.

How to start learning Python

Install the current Python 3 release from the official Python downloads page. Python 2 is no longer maintained, so new programs should use Python 3.

Once installed, check it from the terminal:

python3 --version

You can then start the interactive interpreter:

python3

The >>> prompt lets you try one expression at a time. It is one of the fastest ways to explore the language.

The official Python tutorial is another useful reference. In the following posts I guide you through the same foundations with small, focused examples.

Tagged: Python · All topics
~~~

Related posts about python: