WeThinkCode

WeThinkCode_ IDC Curriculum

Digital Inclusion Program

...

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: Name and name are 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_name instead of x

Next, practice creating different types of variables!