Introduction to Python
Python is the world's most popular language for data science, automation, and AI — and one of the most readable languages ever designed. It is also one of the highest-demand skills in South Africa.
What is Python?
Python was created by Guido van Rossum, first released in 1991. It is an interpreted, dynamically typed, high-level language famous for its philosophy that code should be readable and explicit. Where Java requires public static void main and C# requires using System, Python needs nothing — you just write code and it runs.
Python does not use curly braces for code blocks. Instead it uses indentation — the visual structure of the code is the structure of the program. This forces readable code as a language requirement, not just a guideline.
Why Python is Critical in South Africa
Python dominates data science, machine learning, and automation — three of the fastest-growing sectors in South African technology. Discovery, Standard Bank, and Capitec use Python data pipelines for fraud detection and risk modelling. The Department of Health and Statistics South Africa use Python for epidemiological analysis. Web APIs built with Django and FastAPI are Python-powered. DevOps automation with Ansible and infrastructure tooling are largely Python.
Python is also the primary language taught at South African universities for data science and computational subjects — learning it opens both industry and academic doors.
Your First Python Program
print("Sanibonani, world!")
print("Welcome to Your IT Tutor Python training.")
# Variables and printing on the same line
name = "Thandi"
age = 21
print(f"Hello, {name}. You are {age} years old.")
The REPL — Interactive Python
Type python in your terminal to enter the Python shell (REPL — Read-Eval-Print Loop). Type any expression and see the result immediately. This is invaluable for experimenting.
>>> 2 + 2
4
>>> "hello".upper()
'HELLO'
>>> name = "Sipho"
>>> f"Hello, {name}"
'Hello, Sipho'
>>> exit()
Python vs Java and C#
- No type declarations — just
name = "Thandi", noString name =. - No semicolons — newlines end statements.
- Indentation is syntax — not optional style.
- No class required for a program — scripts run top-to-bottom.
- Dynamic typing — the same variable can hold different types at runtime (though type hints are now common).
- Everything is an object — even integers and functions.
Practice Task
Your Turn
Write a Python script that prints five lines: your full name, city, current year (calculate it using import datetime; datetime.date.today().year), the language you are learning, and a one-sentence description of a problem you want to solve with programming.
Common Mistakes
- Mixing tabs and spaces for indentation — Python raises IndentationError. Use 4 spaces consistently.
- Capitalising
Print— Python is case-sensitive; the function isprint. - Forgetting to close quote marks.
- Using semicolons — they work but are not Pythonic; omit them.
- Running Python 2 — verify with
python --version. You need Python 3.x.
Professional Tip
Python's readable syntax is not a simplification — it reflects decades of thought about what makes code maintainable. When Python feels easier than Java, that is by design.
Mini Quiz
How does Python define code block boundaries?