# Python Numbers: intgers
= 3
a = 4
b = 5
number
print('a:', a)
print('b:', b)
print('number:', number)
a: 3
b: 4
number: 5
In python, there are three types of numbers
int
float
complex
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
# round() rounds a number to a specified number of decimal places
pi = 3.14159265358979
rounded_pi = round(pi, 3)
print('pi:', pi)
print('rounded_pi:', rounded_pi)
pi: 3.14159265358979
rounded_pi: 3.142
# abs() returns the absolute value of a number
number = -5
absolute_value = abs(number)
print('absolute value of', number, 'is', absolute_value)
absolute value of -5 is 5
16
# divmod() returns the quotient and remainder of a division
# division = divmod(10, 3)
quotient, remainder = divmod(10, 3)
print('Quotient:', quotient)
print('Remainder:', remainder)
Quotient: 3
Remainder: 1
A few ads maybe displayed for income as resources are now offered freely. 🤝🤝🤝