Ex: Math Operators

 

#  Demo: math operators
print("Example (operators): +, -, /, =, *, ** (same as pow), // (floor division removes remainder), % mod or modulo (remainder only)")
print("Note that in Python '=' sets a value while '==' is a comparison resulting in true or false.")
print ("(10 + 7 -3)/2 =") 
print ((10 + 7 -3)/2) # + - /
print("5*(2**4) = ")
print(5*(2**4)) # * mutiply and ** exponent
print("truncated division '//' casts off the remainder, 10//3= ", 10//3) #truncated division
print("'%' is the Python character for mod or modulo - returns just the remainer, 10%3= ", 10%3) #modulo
print("divmod(x,y) combines results from // and % - also see next example")
x, y = 10, 3
a, b = divmod(x,y)
print(a, b)