Python Intro
Learn why Python is used for AI, how this course is organised, and run your first program.
Why it matters: Most ML and GenAI tools are written in Python. Start here, then build up.
Basics
What is this course?
This is a free Python course for AI, ML, and GenAI beginners.
You will learn:
- Basic Python syntax
- Data and ML libraries later
- GenAI habits at the end
Each lesson has short text, a tiny example, and a live editor.
Tiny example
Print a short message.
print("Hello, AI engineer")Basics
Why Python?
Python is popular for AI because of its libraries:
- NumPy and pandas for data
- scikit-learn and PyTorch for models
- FastAPI for APIs
You write clear glue code: load data, call a model, show a result.
Tiny example
Store a name, then print it.
model = "gpt-4.1-mini"
print(model)Basics
Your First Program
Python runs from top to bottom.
print()shows output#starts a comment- Indentation matters (use four spaces)
Common mistake: treating indentation as optional. A wrong indent is a syntax error.
Tiny example
Comments and print.
# This is a comment
print("Python runs top to bottom")
print(2 + 2)Then AI / ML
AI / ML examples
Same idea, used in real AI work. Press Try in lab to run it.
AI / ML example
AI / ML: tiny config
Store settings in variables, then print them.
In AI / ML: Training scripts start with small config values like this.
example.py
Python
model_name = "bert-base"
batch_size = 32
print(model_name)
print(batch_size)Takeaways
- 1Python is the main language for ML and GenAI.
- 2print() shows output. # starts a comment.
- 3Indentation is required in Python.