Variables and Data Types in Python: Store and Use Data Like a Pro
In Python, variables are simply names that refer to values. Understanding the main data types makes it easier to choose the right tool for the task.
Core concepts
-
intfor whole numbers -
floatfor decimal numbers -
strfor text -
boolfor True/False values
Example
age = 25
price = 19.99
city = "Istanbul"
is_student = True
print(age, price, city, is_student)
Why it matters
Every real-world program needs to store information: customer names, quantities, prices, or user choices. Choosing the right type helps prevent bugs and makes your logic easier to read.
Real-world example
Imagine a shopping cart: quantity, unit price, and total cost are all stored in variables and calculated by the program.
Where to go next
**_Use this article as the foundation for control flow, where your program makes decisions using the values you store.**
_
Top comments (0)