🏷️ Data Type
5th Grade 💻 Coding
A data type is the kind of value something is: a whole number, a decimal number, text (a string), true/false (a Boolean), a list and more. The type decides what you can do with the value.
Numbers can be added, multiplied and divided. Text can be stuck together and you can count its letters. A Boolean value can be flipped with not. When you mix types without paying attention, you get surprises: "5" + "5" gives "55", and "5" + 5 in Python gives an error.
In Python, the type function tells you the type: type(3.5) gives float (a decimal number), and type("5") gives str (a string). You can convert between types: int("12") turns the text "12" into the number 12, and str(7) turns the number 7 into text.
For example
- Your age is a whole number (11), your height in feet is a decimal number (4.75), your name is a string ("Noah"), and “Do I have a brother?” is a Boolean.
- In Python,
inputalways gives back a string, so you convert a typed-in age to a number withintbefore doing math with it.
📌 Remember: Every value has a type — and the type decides what you’re allowed to do with it.
Quick quiz
What is a data type?
What does type(3.5) give in Python?
What does int("12") do?