In Python, variables are used to store data that can be used and manipulated later in your program. Think of variables as labeled containers for your data.
A variable is a name that refers to a location in memory where a value is stored. In Python, you don't need to explicitly declare variables like in other programming languages, and they are created when you assign a value to them using the =
sign.
Variables in Python can store different types of data. Here are some of the most common data types:
25
.3.14
."Hello"
.name = "Alice"
age = 25
is_student = True
In this example, we created three variables: name
(a string), age
(an integer), and is_student
(a boolean). Python automatically understands the type of data you're working with based on the value you assign to the variable.
Create variables that store your name, age, and whether you are currently learning Python (True or False).
your_name = "Your Name"
your_age = Your Age
learning_python = True