Beginner Chapter 2 · 20 min read · Module 1: Python Fundamentals
History and Features of Python
- After this chapter you can name the creator of Python and say when it was first released.
- You can explain the difference between Python 2 and Python 3 and why Python 2 is no longer used.
- You can list the main features of Python such as dynamic typing, portability and a large standard library.
- You can show a few of these features with small code examples.
- You can read the Zen of Python and explain one of its ideas.
Every tool has a story, and the story of Python helps you understand why the language looks and behaves the way it does. Python was created by a programmer named Guido van Rossum, who wanted a language that was powerful but also pleasant to read and write. The first public release came in 1991, so Python is older than many people expect.
Over the years the language grew from a small hobby project into one of the most widely used languages in the world. A big change came with Python 3, which was released in 2008 and fixed some old design problems. Today Python is developed in the open by a large community of volunteers and companies.
In this chapter you will learn the key moments in Python's history and the features that people love. You will also run small examples that show those features. Knowing the history makes it easier to understand things such as why older tutorials sometimes look different from modern code.
Who created Python?
Python was designed by Guido van Rossum, a programmer from the Netherlands. He began working on it in the late 1980s while he was working at a research institute called CWI. He wanted a language that was easier to use than the tools he had at the time, but still strong enough to do real work. Part of his thinking came from an earlier teaching language called ABC.
The name Python does not come from the snake. Guido was a fan of a British comedy show called Monty Python's Flying Circus, and he chose the name for fun. That is why you will often see jokes from the show in Python examples and documentation. The snake logo came later.
A short timeline
| Year | Event |
|---|---|
| Late 1980s | Guido van Rossum starts designing Python |
| 1991 | First public release of Python |
| 2000 | Python 2.0 is released |
| 2008 | Python 3.0 is released |
| 2020 | Python 2 reaches its official end of life |
| Every year since 2019 | A new Python 3 version arrives each October |
After the first release, Python slowly gained users because it was simple, flexible and free. Python 2.0 added useful things, such as list comprehensions, and moved the project to a more open way of working. Later, the core team decided that some old choices were making the language harder to learn, so they made Python 3 with a cleaner design.
Python 2 and Python 3
Python 3 was not fully compatible with Python 2. That means many programs written for Python 2 would not run on Python 3 without changes. This slowed the move to the new version for a while, but in the end the community moved over. Python 2 stopped receiving updates and security fixes at the start of 2020. Today you should always learn and use Python 3.
One famous difference is print. In Python 2 it was a statement, written like print "Hello". In Python 3 it is a normal function, written with brackets. Another difference is that text strings in Python 3 support Unicode by default, so you can use many languages and symbols without extra work.
import sys
print(sys.version_info.major)
print(sys.version_info.major >= 3)The sys module gives information about the running Python. The value sys.version_info.major is 3 on any modern Python. Programs sometimes check it to make sure they run on the right version.
Main features of Python
1. Simple and readable
Python code is close to plain English and avoids extra symbols. Fewer lines are needed to do the same job compared with many other languages. This makes programs easier to write, read and fix.
2. Interpreted
You can run code straight away without a separate build step. This gives a fast feedback loop, which is perfect for learning and for trying ideas.
3. Dynamically typed
You do not declare the type of a variable. A name can point to an integer now and to text later. Python checks types while the program runs. The values themselves still have a strict type, so Python will not mix them in silly ways.
x = 10
print(type(x))
x = "ten"
print(type(x))
x = 3.14
print(type(x))4. Multi-paradigm
Python supports several styles of programming. You can write simple step-by-step scripts, organise code with functions, build programs with classes and objects, or use ideas from functional programming. You can choose the style that suits the problem.
5. Large standard library
Python is often described as having "batteries included". The standard library comes with modules for maths, dates, files, text, the web and more, so you can do a lot without installing anything.
import math
print(math.sqrt(49))
print(math.pi)
print(math.floor(3.9))6. Portable and cross-platform
The same Python program usually runs on Windows, macOS and Linux with no changes, as long as you do not use features tied to one system. You write once and run in many places.
7. Free and open source
Python costs nothing and its source code is open. The language is looked after by a community, and the non-profit Python Software Foundation protects its rights and supports its growth.
8. Automatic memory management
Python manages memory for you. You do not need to free memory by hand, because the language removes objects that are no longer used. This avoids a whole group of bugs found in lower-level languages.
9. Extensible with packages
Beyond the standard library there are many thousands of extra packages that you install with the pip tool. They cover areas like data science, web development and machine learning.
Newer features worth knowing
Python keeps improving. Since Python 3.6 you can use f-strings to put values inside text. Python 3.8 added the walrus operator :=. Python 3.10 added the match statement, which is a tidy way to compare a value with several patterns. If you use a version older than 3.10, the match example below will give a SyntaxError.
language = "Python"
year = 1991
print(f"{language} was first released in {year}")
code = 404
match code:
case 200:
print("OK")
case 404:
print("Not found")
case _:
print("Other")The Zen of Python
Python has a short poem of guiding ideas called the Zen of Python. Running import this prints it. It includes lines like "Readability counts" and "Simple is better than complex". These ideas explain why Python code is written the way it is.
import thisPython syntax
import module_nameprint(f"text {value}")match value:
case pattern:
statementReal-world applications
- Knowing the history helps you read older Python 2 code and update it to Python 3.
- Dynamic typing lets you write quick scripts and prototypes with little code.
- The large standard library saves time in tasks like reading files or working with dates.
- Portability lets one script run on a teacher's Windows laptop and a server running Linux.
- The open-source community provides free packages for almost any field.
Common mistakes
Fix: That is Python 2 style. In Python 3 always write print("text").
Fix: It is named after the comedy show Monty Python's Flying Circus.
Fix: Types still exist and are checked when code runs. For example, adding a number to text raises a TypeError.
Fix: The match statement needs Python 3.10 or newer. Check your version with python --version.
Important tips
- Always check your version with python --version before following a tutorial.
- Run import this once and read the Zen of Python slowly.
- If code from the internet uses print without brackets, it was written for Python 2.
- Keep your Python up to date to receive fixes and new features.
Key points summary
- Python was created by Guido van Rossum and first released in 1991.
- Python 3.0 came out in 2008 and Python 2 reached end of life in 2020.
- Python is simple, interpreted, dynamically typed and open source.
- The standard library is large and a lot of packages are available.
- The same code usually runs on Windows, macOS and Linux.
- Newer features such as f-strings and match make code cleaner.
Exam and interview points
- Creator: Guido van Rossum. First release: 1991.
- Python 3.0 was released in 2008. Python 2 ended in 2020.
- Python is interpreted, dynamically typed, high-level and object-oriented.
- Python supports multiple programming paradigms.
- Python is portable and open source, managed by the Python Software Foundation.
Quick revision
- Guido van Rossum, 1991, named after Monty Python.
- Python 3.0 in 2008, Python 2 ended in 2020.
- Features: simple, interpreted, dynamic, portable, free.
- Standard library = batteries included.
- f-strings from 3.6, match from 3.10.
- import this prints the Zen of Python.
Frequently asked questions
Who invented Python?
Guido van Rossum created Python. He started it in the late 1980s, and it was first released in 1991.
Why is it called Python?
The name comes from the British comedy group Monty Python, not from the snake.
Should I learn Python 2 or Python 3?
Learn Python 3. Python 2 reached end of life in 2020 and no longer receives fixes.
What does dynamically typed mean?
You do not declare the type of a variable. The type belongs to the value, and Python checks it while the program runs.
Is Python free for commercial use?
Yes. Python is open source and can be used freely, including in commercial projects.
Practise this chapter
20 practice questions Take the chapter quiz