Variables and Data Types
Variables in Python are used to store values so that we can use them later in a program. They act like containers that hold information such as numbers, text, or other data.
What are Data Types?
Data types define what kind of data is stored in a variable, such as:
- Integer (
int) → Whole numbers - String (
str) → Text or words - Float (
float) → Decimal numbers
Real-Life Analogy
Think of variables like labeled boxes.
- A box labeled Fruits stores fruits.
- A box labeled Books stores books.
Similarly, Python variables store different kinds of data so the computer can understand and use them correctly.