Opening
🤔 What Do You Think?

- A computer screen filled with colorful lines of Python code, including words starting with # and words next to equals signs.
Slide 1
What Are Comments in Python?
- Comments are notes in Python code that start with a # and explain what the code does.
- Comments help programmers understand code, like leaving reminders or instructions in a notebook.
- For example, # This prints a greeting is a comment that tells us the next line will show a message.
- Comments
- — Notes in code starting with # that explain what the code means.
Check for understanding
Check Your Understanding
Slide 2
Creating and Using Variables in Python
- Variables store values like words or numbers, and you give them names to use later.
- In Python, you assign a value to a variable with the = sign, like name = "Alex".
- Example code: name = "Alex" print(name) outputs: Alex
- Variables
- — Names that store information like numbers or text in code.
- Assignment
- — Giving a value to a variable using the = sign.
Check for understanding
Check Your Understanding
Slide 3
Variable Naming Rules and Unpacking
- Variable names must start with a letter or underscore and cannot use spaces or special characters.
- You can assign values to multiple variables at once, like x, y = 5, 10 which sets x=5 and y=10.
- Unpacking means taking values from a list or tuple and saving them into variables, like colors = ["red", "blue"] followed by first, second = colors.
- Unpacking
- — Taking multiple values from a list and saving them into variables at once.
Check for understanding
Check Your Understanding
Slide 4
Using Comments and Variables Together
- You can write comments before variables to explain what each variable means, like # Player's score.
- Example code: # Player's score score = 10 print(score) outputs: 10
- Comments and clear variable names make your code easier to read and debug for yourself and others.
- Debug
- — Finding and fixing mistakes in your code.
Check for understanding
Check Your Understanding
Check for understanding
Solo Run: Variables and Comments
Exit check