# Python Numbers: intgers
= 3
a = 4
b = 5
number
print('a:', a)
print('b:', b)
print('number:', number)
a: 3
b: 4
number: 5
Juma Shafara
November 1, 2023
python numbers
In python, there are three types of numbers
int
float
complex
Before we continue, we have a humble request, to be among the first to hear about future updates of the course materials, simply enter your email below, follow us on (formally Twitter), or subscribe to our YouTube channel.
An integer is a number without decimals
A floating point number of just a float is a number with decimals
A comple number is an imaginary number. To yield a complex number, append a j
o J
to a numeric value
Number methods are special functions used to work with numbers
55
# round() rounds a number to a
# specified number of decimal places
pi = 3.14159265358979
rounded_pi = round(pi, 3)
print(pi) # 3.14159265358979
print(rounded_pi) # 3.142
pi: 3.14159265358979
rounded_pi: 3.142
# abs() returns the absolute value of a number
number = -5
absolute_value = abs(number)
print(absolute_value) # 5
absolute value of -5 is 5
# pow() returns the value of
# x to the power of y
four_power_two = pow(4, 2)
print(four_power_two) # 16
16
# divmod() returns the quotient and
# remainder of a division
quotient, remainder = divmod(10, 3)
print(quotient) # 3
print(remainder) # 1
Quotient: 3
Remainder: 1