Understanding data types

Understanding Data Types: How Computers See the World

Not all data is the same.
To a computer, numbers, text, and lists are completely different things, and each has its own rules. That’s where data types come in.

What Is a Data Type?

A data type tells the computer what kind of value it’s dealing with.
Here are the most common ones in Python:

# Text
name = "YourName"        # str (string)

# Number
age = 28               # int (integer)

# Decimal
height = 1.75          # float

# True/False
is_coder = True        # bool (boolean)

# List of items
skills = ["Python", "HTML", "CSS"]  # list

Each type behaves differently, and choosing the right one helps your code work properly.

Why It Matters

  • You can’t add text to a number without converting it
  • Lists let you store multiple values in one place
  • Booleans help with decision-making (True/False logic)

Real-Life Analogy

Think of a spreadsheet:

  • Text goes in one column
  • Numbers in another
  • Checkboxes for True/False
  • Dropdowns for lists

Each cell has a type, and so does each variable in your code.

What’s Next?

In the next post, we’ll explore if statements; how to make decisions in code using logic and conditions.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top