← Back to Blog

Not All Values Are the Same

The problem...

You know how to store values. But not all values are the same.

A name is not a number. A number is not true or false.

If you treat them the same way, things break.

The idea!

Every value in Python has a type. That type tells Python what the value is and what you can do with it.

Making it real

Think of it like this: you wouldn't add a name to a number. It doesn't make sense.

Python thinks the same way. It needs to know what kind of value it's working with.

The four basic types

For now, there are four you need to know:

  • str — text. Example: "Bull"
  • int — whole numbers. Example: 25
  • float — decimal numbers. Example: 3.14
  • bool — true or false. Example: True

In practice

name = "Bull"
age = 25
height = 1.80
active = True

What happens?

  • name is a str
  • age is an int
  • height is a float
  • active is a bool

Same structure. Different types.

Why this matters?

Python behaves differently depending on the type.

25 + 25 gives you 50.

"Bull" + "25" gives you "Bull25".

Same operator. Different result. Because the types are different.

How to check the type

name = "Bull"
print(type(name))

Output → <class 'str'>

Python tells you exactly what it's working with.

What's really happening

You're not just storing values. You're storing values that have meaning.

Python uses that meaning to decide what's allowed and what isn't.

The mindset shift

Stop thinking: "I have a value."

Start thinking: "I have a value. And it has a type."

What you should understand now

  • Every value in Python has a type
  • Types decide what you can do with a value
  • str, int, float, bool are the four basics
  • You can always check the type with type()
[ login to bookmark ] // copied! 46 views · 1 min
// resources
Code Example data_types.py
← prev Variables (and why they’re not what you think) next → Text is Data Too
// 0 comments
// No comments yet. Be the first.
// leave a comment

// Your comment will appear after approval.