Integer and float numbers - Learn Python 3 - Snakify

Lesson 2. Integer and float numbers




10/10. Some functions from math module

All the functions of any standard Python module are documented on the official Python website. Here's the description for math module. Arguably most popular functions are:

floor(x) — returns the largest integer less than or equal to x,

ceil(x) — returns the smallest integer greater than or equal to x,

sqrt(x) — returns the square root of x,

log(x) — returns the natural logarithm of x,

log(x,a) — returns the logarithm of x to base a,

pi is the mathematical constant pi = 3,1415926..

e — is the mathematical constant e = 2,71828..

sin(x) returns the sine of x in radians

cos(x) returns the cosine of x in radians

tan(x) returns the tangent function of x

asin(x) returns the arcsine of x in radians

Instructions

Click "Run" to see what happens in output!

Congratulations! Now you're guru of ints and floats!
# remember the rules:
# if you use "import math",
# you must call the desired function like
# math.sqrt(x)
# or
# math.cos(y)

# But if you use "from math import cos"
# this is how you call the function: 
# cos(x)
# Then, if you what to calculate a logarithm,
# you need to write "from math import log"
# and then you may call your logarithm
# with log(y) or log(z,10)