Python Math

Basic Operators:

3 + 4 # Addition 3 - 4 # Subtraction 3 * 4 # Multiplication 3 / 4 # Division 3 // 4 # Integer division (rounds answer down to nearest integer) 3 % 4 # Modulus (remainder after division) 3 ** 2 # Exponents/powers (e.g. 3 to the power of 2) 9 ** (1/2) # Square root (9 to the 1/2 power, which is the square root of 9)

- You can put any of these in a print function or store it as a variable

Trigonometry:

math.sin( math.pi / 2 ) # Sine math.cos( math.pi ) # Cosine math.tan( math.pi / 4 ) # Tangent math.asin( 1M ) # Arcsine math.acos( 1 ) # Arccosine math.atan( 1 ) # Arctangent

- The math library will have to be imported to use its functions

Logarithms:

math.log( math.e ) # Natural log (of e) math.log2( 8 ) # log base 2 (of 8) math.log10( 100 ) # log base 10 (of 100) math.log( 25, 5 ) # log base 5 of 25

Other:

math.sqrt(25) # Alternative square root

Challenge

Write code that will display the square root of the fraction of 11 divided by pi, but don't use any number besides 1 in the code.

Completed