Menu

1 / 2

Variables and Data Types in Python

DEV Community: tutorial·Nicholus Mush·5 months ago
#6k5aJNqh
#dev#variables#store#values#makes
Reading 0:00
15s threshold

Nicholus Mush

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

  • int for whole numbers
  • float for decimal numbers
  • str for text
  • bool for True/False values

Example

age = 25
price = 19.99
city = "Istanbul"
is_student = True
print(age, price, city, is_student)

Enter fullscreen mode Exit fullscreen mode

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.**
_