# By Juma Shafara# Python Numbers: arthmeticssummation =4+2print('sum:', summation)difference =4-2print('difference:', difference)product =4*2print('product:', product)quotient =4/2print('quotient:', quotient)
sum: 6
difference: 2
product: 8
quotient: 2.0
Number Methods
Number methods are special functions used to work with numbers
# sum() can add many numbers at oncesummation =sum([1,2,3,4,5,6,7,8,9,10])print(summation)
55
# round() rounds a number to a specified number of decimal placespi =3.14159265358979rounded_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 numbernumber =-5absolute_value =abs(number)print('absolute value of', number, 'is', absolute_value)
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
# divmod() returns the quotient and remainder of a division# division = divmod(10, 3)quotient, remainder =divmod(10, 3)print('Quotient:', quotient)print('Remainder:', remainder)