 Curiosity, learning and homework help

:

### MEMBERS

 Come to discuss on the forum!■ FAST and FREE signup. ■ 😀 Access to discussion forums 😀 Help for HOMEWORKS, support in COMPUTER SCIENCE, help for learning FRENCH and ENGLISH, discussion on your INTERESTS and HOBBIES...

Some mathematical functions in Python 3.x
In Python 3.x, to be able to use mathematical functions, you need to import the Python math library with the following command line:
import math

Then, all mathematical functions from the math library become available.

Example :
>> import math
>> math.cos(math.pi)

This succession of instructions returns the value of $$cos(\pi)$$, namely -1.

Here is a non-exhaustive list of the functions available in the Python math library:

• To calculate the logarithm of a number (natural logarithm to base $$e$$): $$\ln(x)$$
• math.log(x)

• To calculate the exponential of a number: $$e^x$$ (ou $$\exp(x)$$)
• math.exp(x)

• To calculate the square root of a number: $$\sqrt{x}$$
• math.sqrt(x)

• To calculate the cosine of a number: $$\cos(x)$$
• math.cos(x)

• To calculate the sine of a number: $$\sin(x)$$
• math.sin(x)

• To calculate the tangent of a number: $$tan(x)$$
• math.tan(x)

• To use the number pi: $$\pi$$
• math.pi

• To calculate the power of a number: $$x^y$$
• math.pow(x,y)

• To get the closest integer smaller than a number (the integral part): the greatest integer less than or equal to x
• math.floor(x)

• To get the closest integer greater than a number: the smallest integer greater than or equal to x
• math.ceil(x)

• To calculate the absolute value of a number: $$\lvert x \rvert$$
• math.fabs(x)

• To calculate the factorial of an integer: $$x!$$
• math.factorial(x)

If you have any comments or questions about the math library of Python 3.x, you can discuss them in the forum: Discussion forums.