This is an archived version of the course. Please find the latest version of the course on the main webpage.

Chapter 4: Objects

Object types

face Josiah Wang

As mentioned, an object has a type.

Python provides the following basic data types.

  • Numbers: int, float, complex
  • Boolean: bool (Something that is either True or False)
  • Strings: str (A sequence of characters)

You can check the type of an object using type().

>>> type(3)
<class 'int'>
>>> type(5+2j)
<class 'complex'>
>>> type("London")
<class 'str'>