Skip to content

Numbers and Booleans (int · bool) ​

int (Integer) ​

Definition: A data type for whole numbers without a decimal point

Features

  • Can represent positive numbers, negative numbers and 0
  • Supports arithmetic (+, -, *, /)
python
age = 25
score = 100
negative = -10

print(type(age))        # output: <class 'int'>
print(score + 10)       # output: 110
print(score // 3)       # output: 33 (integer division)

bool (Boolean/Logical Value) ​

Definition: A data type with only two values, True or False

Features

  • Often used as the result of comparisons
  • True is also treated as 1 and False as 0
python
is_student = True
is_adult = False

print(type(is_student))         # output: <class 'bool'>
print(5 > 3)                    # output: True
print(10 == 5)                  # output: False
print(bool(0))                  # output: False
print(bool(1))                  # output: True

Summary ​

ConceptSummary
intInteger data type → number calculations
boolTrue/False data type → expressing conditions

Reference: personal Notion study notes (onboarding course)