Tsallaka zuwa abun ciki
Justice Tech School

Data Types

Every value has a type. The common ones are str (text), int (whole number), float (decimal), bool (True or False), list, tuple, set, dict and NoneType. The type() function tells you which one you have, and isinstance() checks a type.

Example
print(type("hi"))
print(type(7))
print(type(3.14))
print(type(True))
print(type([1, 2]))
print(type({"a": 1}))
print(isinstance(7, int))

Result

<class 'str'>
<class 'int'>
<class 'float'>
<class 'bool'>
<class 'list'>
<class 'dict'>
True

Exercise

Find the type of a value.

print((42))

Quiz Test

Which type is 3.0?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.