# 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
November 25, 2024
python numbers, number types, number arithmetics, number methods
In this notebook, you will learn the following
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
Below are some of the basic arithmetic operations that can be performed with numbers
Number methods are special inbuilt 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: ', pi) # 3.14159265358979
print('Rounded PI: ', 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
Write a program to assign the number 64.8678 to a variable named “number” then display the number rounded to two decimal places.