π Pythonπ
Day 1
Introduction to Python
What Python is, why it is popular, how the interpreter works, and how to run your first Python program.
π―
Learning objectives
- βUnderstand what Python is and where it is used
- βLearn the difference between compiled and interpreted languages
- βRun your first Python program
π‘ Key points
- Python is a dynamically-typed, high-level, interpreted language.
- Popular for data science, ML, web (Django/Flask), automation and scripting.
- Indentation is part of the syntax β code blocks use whitespace, not braces.
- Two current versions: Python 3.x is the standard (Python 2 is retired).
π» Code examples(3)
#1Hello World
pythonprint("Hello, World!")
Output
Hello, World!
No class, no main, no semicolons. print() writes to standard output with an automatic newline.
#2Run a script
bashpython3 hello.py
Save the code as hello.py and run it. On Windows the command is usually just python.
#3Interactive shell (REPL)
python>>> 2 + 3
5
>>> name = "Priya"
>>> print(f"Hi {name}")
Hi Priya
Start the REPL with python3. Great for quick experiments.
π― Practice
Q1. Is Python compiled or interpreted?+
Interpreted β source code is executed by the Python interpreter at runtime. (Internally it compiles to bytecode first, but you don't see that step.)
Q2. What is the correct file extension for Python source?+
.py
Q3. Print your name using an f-string.+
name = "Amit"; print(f"Hello {name}")
π Notes
Why Python?
- Readable syntax close to English.
- Huge standard library plus PyPI (400k+ packages).
- Dominant in AI/ML (NumPy, Pandas, PyTorch, TensorFlow).
- Used by Google, Instagram, Netflix, Dropbox.
Setting up
- Install Python 3 from python.org or your package manager.
- Verify with
python3 --version. - Use a virtual environment for each project:
python3 -m venv .venv.