Home Tutorials Python Tutorial Variables
Variables

Variables


Definition: Variables are names used to store data values. They act as containers for storing data that can be used and changed throughout your program.

Why: Variables are introduced early because almost every programming task involves storing, updating, or retrieving data.

Syntax

variable_name = value

Example

age = 20
city = "Bengaluru"
price = 99.5

print(age)
print(city)
print(price)

Explanation

  • age, city, and price are the variable names.
  • Python creates a variable automatically the moment you assign a value to it using the = sign.
  • A variable can store different types of data, such as whole numbers, decimal numbers, or text strings.

Key Notes

  • Variable names should be descriptive (e.g., user_age instead of just a).
  • Variable names are case-sensitive (age and Age are different variables).
  • In Python, you do not need to declare the type of variable; it is determined automatically.
Example

🏋️ Test Yourself With Exercises

Take our quiz on Variables to test your knowledge.

Exercise »