Back to course

The Boolean Data Type (bool) and Type Checking

Python Programming: The 0 to Hero Bootcamp

Booleans (bool)

Booleans represent truth values. They can only hold one of two possible values: True or False. Note that they must be capitalized.

Booleans are fundamental to decision-making in programming (control flow).

python is_sunny = True has_passed = False user_logged_in = True

Determining Data Type (type() function)

Python is dynamically typed, meaning you don't declare the type of a variable beforehand. The type() function tells you what type a variable currently holds.

python my_int = 42 my_float = 3.14 my_bool = True

print(type(my_int)) print(type(my_float)) print(type(my_bool))

Output:

<class 'int'> <class 'float'> <class 'bool'>