""" Purpose: demonstrate arithmetic """ # Name some variables and print their values a = 20 b = 3 print( "Values of interest" ) print( "a:", a ) print( "b:", b ) print() # Perform calculations total = a + b # the variable total will be equal to the sum of the values of variables a and b. 20 + 3 difference = a - b product = a * b dec_quotient = a / b # this is decimal division. the result can be a decimal int_quotient = a // b # this is integer division. the result will be an int. it will cut off the remainder. ex: 6.333->6 power = a ** b # exponentiation. this can be used to take the root. ex: a ** (1/2) is square root of a remainder = a % b # the remainder when a is divided by b. 20/3, 2 is the remainder # since 3 goes into 20 six times, w/ 2 left over # good programming tip: don't do arithmetic/operations within a print() statement # having spaces around operators (i.e. *, +, =) is for readability # python has libraries (such as the math library) for importing functions we can use # you can do many operations on one line, but spreading up your commands over several lines is more readable # your computer can't store infinite numbers, so it provides an approx. when the number is too large. # 15-16 digits is the max # Print results print( "Results" ) print( "a + b: ", total ) # this will print the literal string "a + b:", then the value of the variable total print( "a - b: ", difference ) print( "a * b: ", product ) print( "a / b: ", dec_quotient ) print( "a // b:", int_quotient ) print( "a ** b:", power ) print( "a % b: ", remainder )