Storing Things: Variables
Variables in Python
Variables are like labeled boxes where you can store information. You give each box a name, and you can put different types of things inside.
Creating Variables
name = "Alex"
age = 16
height = 170.5
is_student = True
Variable Names
- Can contain letters, numbers, and underscores
- Must start with a letter or underscore
- Cannot be Python keywords (like
print,if,for) - Case-sensitive:
Nameandnameare different
Data Types
- Strings: Text in quotes, like
"Hello" - Integers: Whole numbers, like
42 - Floats: Decimal numbers, like
3.14 - Booleans: True or False values
Remember
- Variables make your code reusable
- You can change a variable's value anytime
- Use descriptive names like
student_nameinstead ofx
Next, practice creating different types of variables!
Storing Things: Variables
Variables in Python
Variables are like labeled boxes where you can store information. You give each box a name, and you can put different types of things inside.
Creating Variables
name = "Alex"
age = 16
height = 170.5
is_student = True
Variable Names
- Can contain letters, numbers, and underscores
- Must start with a letter or underscore
- Cannot be Python keywords (like
print,if,for) - Case-sensitive:
Nameandnameare different
Data Types
- Strings: Text in quotes, like
"Hello" - Integers: Whole numbers, like
42 - Floats: Decimal numbers, like
3.14 - Booleans: True or False values
Remember
- Variables make your code reusable
- You can change a variable's value anytime
- Use descriptive names like
student_nameinstead ofx
Next, practice creating different types of variables!
main.py
Loading...
Click "Run Code" when you are ready to test your solution.
