Python: Your New Superpower πŸš€

The beginner-friendly guide to coding like a pro.

What is Python?

Python is a high-level language, which means it reads almost like English. It's used by **NASA**, **Netflix**, and **Spotify**. If you can write a recipe for a sandwich, you can write Python!

1. The Terminal: The "Engine Room"

Think of your computer as a car. The icons and mouse are the steering wheel, but the Terminal is the engine. It's a text-based window where you give direct commands to the computer.

$ python --version
Python 3.10.12
$ print("Hello World")
Hello World

Google Colab Tip: In Colab, you don't need a terminal window. Each "Code Cell" acts like a mini-terminal!

2. Python Syntax (The Rules)

In English, we use periods and capital letters. In Python, the most important rule is Indentation. It's how Python knows which lines of code go together.

The "If" Rule: If you use a colon :, the next line MUST have a big gap (4 spaces or 1 Tab).
if 5 > 2:
    print("Python is easy!") # This is indented!
else:
    print("This won't happen.")

3. Variables: The Storage Boxes

Imagine you have boxes and you put labels on them. That's a variable!

Code What it means
player_name = "Alex" Stores text (called a String)
score = 100 Stores a whole number (called an Integer)
is_game_over = False Stores a Yes/No value (called a Boolean)

4. Comments: Notes for You

Use the # symbol to write notes. Python will ignore everything after it. It’s like leaving a "Post-it" note on your code.

# This is a comment. Python won't run this.
print("But it will run this!")

Ready to try it in Google Colab?

Open a new notebook and type your first print() function!