What is Python?
Python is a high-level, general-purpose programming language created by Guido van Rossum and first released in 1991. It's known for readable code: it uses indentation instead of curly braces, and its syntax reads close to English.
- Web backends: Django, FastAPI, Flask
- Data analysis & AI: pandas, NumPy, PyTorch
- Automation & scripting: reports, file processing
- APIs for mobile apps (Flutter, React Native)
- DevOps, testing, scraping, IoT
- Interpreted: runs line by line, with no separate compile step
- Dynamically typed: you don't declare variable types
- Batteries included: a huge standard library
- Multi-paradigm: procedural, OOP and functional
- Indentation matters: 4 spaces define code blocks
Install Python on your computer
- Download Python 3.12 or newer from python.org/downloads. On Windows, tick "Add python.exe to PATH" during install.
- Install VS Code and the Python extension (by Microsoft).
- Check the install in a terminal:
# terminal python --version # Windows python3 --version # macOS / Linux → Python 3.12.x or newer python3 # opens the interactive shell (REPL); type exit() to leave >>> 2 + 3 5
Your first program
Create a file hello.py, type the code below, save it, and run python3 hello.py in the terminal. Or just press ▶ Run here.
# hello.py
print("Hello, World!")
print("Welcome to Ralfiz Technologies")
print("Python", "is", "fun") # multiple values are separated by a space
print("2026", "11", "09", sep="-") # custom separator
print("Loading", end="... ") # end controls what comes after (default: new line)
print("done!")
Comments and indentation
# comments_indentation.py
# This is a single-line comment. Python ignores it.
"""
Triple-quoted strings are often used as multi-line notes
or as documentation (docstrings) for functions and classes.
"""
age = 20
if age >= 18:
print("Adult") # 4 spaces of indentation = inside the if block
print("Can vote")
print("This line always runs") # back to no indentation = outside the block
How Python runs your code
hello.py (source) → Compiled to bytecode (.pyc) → Python Virtual Machine → Output
You don't need to compile anything yourself. python3 file.py does it all.
Exercise solutions
Try each exercise yourself first. Then compare with these.
Exercise 1. Print your name, college and city on three separate lines.
Exercise 2. Print Ralfiz|Technologies|Kerala using one print() with three values and the sep argument.
print("Ralfiz", "Technologies", "Kerala", sep="|")
Exercise 3. Print this pattern using exactly three print statements:* / * * / * * *
print("*")
print("* *")
print("* * *")