DEV Community

Cover image for 🧠 Understanding Data Types (The Missing Layer)
still-purrfect
still-purrfect

Posted on

🧠 Understanding Data Types (The Missing Layer)

After working on input and output in Python, I started noticing something small… but important.
I could collect data. I could display it.
But I didn’t really understand what kind of data I was working with.And that’s where data types came in.
At first, I was writing code like this:

name = input("Enter your name: ")
age = input("Enter your age: ")
Enter fullscreen mode Exit fullscreen mode

Everything worked… until I tried to use age as a number.
That’s when I learned:

Python doesn’t just store values it stores types of values.

🔢 Integers (Whole Numbers)

age = 21
Enter fullscreen mode Exit fullscreen mode

Integers are straightforward they represent whole numbers without decimals.
They’re typically used for counting, indexing, or anything that doesn’t require fractional values.

🌊 Floats (Decimal Numbers)

weight = 55.5
Enter fullscreen mode Exit fullscreen mode

Floats represent numbers with decimal points.
They’re useful when precision matters like measurements, calculations, or averages.

💬 Strings (Text Data)

name = "Maryanne"
Enter fullscreen mode Exit fullscreen mode

Strings are sequences of characters essentially text.
This is what input() returns by default, which explains why:

age = input("Enter your age: ")
Enter fullscreen mode Exit fullscreen mode

…doesn’t behave like a number unless you convert it.

✅ Booleans (True/False Values)

is_student = True
Enter fullscreen mode Exit fullscreen mode

Booleans represent logical values:

  • True
  • False They are commonly used in decision-making within programs.

🔄 Connecting Back to Input & Output

One key realization for me was this:

age = input("Enter your age: ")
Enter fullscreen mode Exit fullscreen mode

Even if I type 21, Python still treats it as a string.
To use it as a number, I have to convert it:

age = int(input("Enter your age: "))
Enter fullscreen mode Exit fullscreen mode

That small change makes a big difference in how the program behaves.

🌱 Final Thoughts

Understanding data types helped me move from just writing code… to actually thinking like a programmer.
Now, before I perform any operation, I pause and ask:

What type of data am I working with?
Because in Python, the difference between a string and an integer isn’t small it completely changes what your code can do.

If you’re learning Python too, this is one concept worth slowing down for.
It makes everything that comes next much easier.

Top comments (0)