TOPIC 2: Variables, Data Types & Operators
Completion requirements
1. What is a Variable?
A variable is a name that holds a reference to a data object. Python allows you to create variables and assign values without needing to declare their types explicitly (Python uses dynamic typing).
Syntax for Declaring Variables:
variable_name = value
Example 1:
age = 30 # Integer
name = "Alice" # String
Here:
- age holds an integer value of 30.
- name holds a string value "Alice".
Example 2:
is_active = True # Boolean
height = 5.9 # Float
Here:
- is_active is a boolean variable set to True.
- height is a float variable set to 5.9.