What is Python?
Python is a programming language created in 1991 by Guido van Rossum, a Dutch programmer who wanted a language that was easy to read, fun to write, and powerful enough for real work. He named it after the British comedy group Monty Python, not the snake.
Three decades later, Python is the most widely used language in the world for data science, machine learning, and artificial intelligence. It also powers websites, automation scripts, scientific research, and tools you use every day.
Python is:
- Interpreted — your code runs line by line through a program called the Python interpreter. No separate compile step.
- Dynamically typed — variables figure out their type from the value you give them. You can still add type hints to get the safety of static typing, which we’ll do throughout this course.
- Readable — Python uses indentation (whitespace) instead of curly braces. Code reads almost like English.
- Batteries included — a huge standard library ships with the language, so you can do a lot without installing anything extra.
- Open source — free to use, with a community of millions.
Why is Python the language of AI?
A few reasons stack up:
- A massive ecosystem of scientific libraries — NumPy, Pandas, scikit-learn, PyTorch, TensorFlow, Hugging Face. Almost every serious ML tool has a Python API first.
- Easy for non-programmers — researchers, scientists, and analysts can pick up Python in weeks. That brought a flood of talent to the language.
- Notebooks — tools like Jupyter let you run Python a piece at a time and see results immediately. Perfect for exploring data.
- Glue language — Python is great at calling fast code written in C, C++, or Rust. NumPy is mostly C; PyTorch is mostly C++. You get Python’s friendliness on top of C-speed underneath.
If you’re heading toward AI, you’ll meet Python everywhere.
What can you build with Python?
A lot more than just ML:
- Machine learning and AI — model training, data pipelines, large language models
- Data analysis — turning raw data into insights using Pandas, NumPy, Matplotlib
- Web backends — sites and APIs with Django, FastAPI, Flask
- Automation — scripts that move files, scrape websites, send emails
- Scientific computing — physics, biology, astronomy simulations
- DevOps tooling — Ansible and SaltStack are written in Python
- Education — most universities now teach intro programming in Python
It’s not a typical choice for mobile apps, game engines, or systems software that needs raw speed. But for everything else, Python is often the shortest path from idea to working code.
What Python looks like
Here’s a complete Python program that prints a greeting:
def main() -> None:
print("Hello, Python!")
if __name__ == "__main__":
main()
Run it:
python hello.py
Hello, Python!
A few things to notice:
def main() -> None:defines a function calledmain. The-> Noneis a type hint — it tells the type checker the function doesn’t return any value.- Python uses indentation to mark blocks of code. The four spaces in front of
print(...)tell Python “this line belongs tomain”. if __name__ == "__main__":is a common pattern that means “only run this when the file is executed directly”. We’ll cover it in Section 11.
You could shorten this whole file to one line: print("Hello, Python!"). Both work. We’ll start with the longer form because it’s the shape every real Python program takes.
What’s next
In the next lesson, we’ll install Python on your machine using a modern tool called uv — and skip a lot of the headaches older Python tutorials run into.