Variables and Data Types

Variables in Python are used to store information or values that can be used later in a program.

They act like containers or boxes where we keep data such as numbers, text, or other values.

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

Variables are 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.