Python – Variables
Variables in Python
Variables are used to store data values. A variable is created the moment you first assign a value to it.
Rules for Naming Variables
- Variable names must start with a letter (a-z, A-Z) or an underscore (_).
- Variable names can contain letters, numbers (0-9), and underscores.
- Variable names are case-sensitive (e.g.,
myVar
andmyvar
are different variables).
Assigning Values to Variables
You can assign values to variables using the assignment operator (=
).
# Assigning values to variables
name = "Alice"
age = 30
height = 5.7
is_student = True