Python Math Module Functions - Programming Examples Tutorial

Veröffentlicht am: 27 August 2021
auf dem Kanal: Appficial
4,554
25

Basic math can be down with + - * /, but for some more advanced math operations (such as square root), python provides a standard math module.

A module is Python code located in another file. To import the module for use within your own python file, or in an interactive interpreter, add the import statement at the top of a file. To use the math module, add import math at the top of your program.

The math module provides functions which are operations that you can use in your program, such as sqrt() for square root or pow() for power. Using the function is referred to as a function call. The data that is passed to a function call is called an argument. Some functions have multiple arguments, such as math.pow(2, 3), which returns 2 to the 3rd power

Constant math values:
e: 2.718281…
pi: 3.141592…

Numbers and theoretic math functions:
ceil(x): Round value up
fabs(x): Absolute value
factorial(x): Factorial, such as (4! = 4*3*2*1)
floor(x): Rounds value down
fmod(x,y): Remainder of division
fsum(x): Floating-point sum of a range, array or list

Exponential, power, and logarithmic math functions:
exp(x): Exponential function ex
log(x, (base)): Natural logarithm with optional base
pow(x, y): x raised to the power of y
sqrt(x): Square root of x

Trigonometric math functions:
acos(x): Arc cosine
asin(x): Arc sine
atan(x): Arc tangent
atan2(x): Arc tangent with 2 parameters
cos(x): Cosine
cosh(x): Hyperbolic cosine
degrees(x): Convert from radians to degrees
hypot(x1, x2, …, xn): Length of vector from origin
radians(x): Convert degrees to radians
sin(x): Sine
sinh(x): Hyperbolic sine
tan(x): Tangent

Complex number math functions:
gamma(x): Gamma function
erf(x): Error function


Subscribe to Appficial for more programming videos coming soon. Also, don't forget to click LIKE and comment on the video if it helped you out!


Auf dieser Seite können Sie das Online-Video Python Math Module Functions - Programming Examples Tutorial mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Appficial 27 August 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 4,554 Mal angesehen und es wurde von 25 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!