Last updated

Python Data Types

Definition: A data type is the kind of a value — such as a number, text, or list. The type decides what you can do with the value.

The common built-in types

intwhole number10
floatdecimal number3.14
strtext (string)"hello"
booltrue/falseTrue
listordered collection[1, 2, 3]
dictkey/value pairs{"a": 1}

Example 1 — checking a type

Use type() to ask Python what type a value is:

print(type(10))
print(type(3.14))
print(type("hello"))
print(type(True))

Example 2 — Python chooses the type for you

a = 5        # int
b = 5.0      # float
c = "5"      # str
print(type(a), type(b), type(c))

Notice 5, 5.0, and "5" are three different types even though they look similar.

💡 Why it matters: 5 + 5 is 10, but "5" + "5" is "55" (joined text). The type changes the behaviour.

Try it Yourself
Output

          
Ad · responsive