Back
+10 XP
Concept

Checking Types with type()

When you have no clue what kind of data is stored in a variable, ask Python with `type()`:

python
print(type(42))    # <class 'int'>
print(type("42"))  # <class 'str'>
print(type(42.0))  # <class 'float'>

# 22. Checking Types with type() When you have no clue what kind of data is stored in a variable, ask Python with `type()`: ```python print(type(42)) # <class 'int'> print(type("42")) # <class 'str'> print(type(42.0)) # <class 'float'> ``` It tells you whether Python sees the data as a whole number, text, or a decimal.

Checkpoint

What does `type("hello")` return?

Practice

Create `mystery = 99.5` and print its type with `type()`.

Terminal
01
Tap code blocks below to assemble
Available Blocks