Python Data Types

Built-in types and how to check them.

✍️ 3 exercises + code challenge in this lesson

Python has many built-in data types:

  • Text: str
  • Numbers: int, float, complex
  • Sequences: list, tuple, range
  • Mapping: dict
  • Sets: set, frozenset
  • Boolean: bool
  • None: NoneType

Use type() to see a value's type.

Key Takeaways: Python Data Types

Mastering Python Data Types helps you write clean and reliable Python code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

Python Data Types Code Example

Python
values = ["text", 20, 20.5, 1j, ["a", "b"], ("a", "b"), range(3),
          {"name": "Sara"}, {"a", "b"}, True, None]

for v in values:
    print(repr(v).ljust(18), type(v).__name__)
Free sign-in required · Google login available

Python Data Types Practice Exercises

Check what you learned in “Python Data Types”.

/ 3 solved
Fill in the blank

Get the type of a value.

(42)
✓ Correct! Not quite. Try again.
Multiple choice

What is the type of 3.14?

✓ Correct! Not quite. Try again.
Code challenge

Print the name of the type of [1, 2] (it should print list).

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services