Skip to main content

Integer Data Type

An integer in Python represents any whole number. It can be positive, negative, or zero.

Examples

# Creating integers
age = 30 # 30 is a whole number
money = 100 # 100 is a whole number
self_esteem = -50 # -50 is a whole number, even if negative

# Performing mathematical operations
a = 5
b = 10

# Addition
sum_result = a + b # Output: 15

# Subtraction
difference = a - b # Output: -5

# Multiplication
product = a * b # Output: 50

# Division
quotient = a / b # Output: 0.5 (Note: This result is a float)

# Checking the type after division
print(type(quotient)) # Output: <class 'float'>