Current location - Training Enrollment Network - Mathematics courses - How does python do math function problems?
How does python do math function problems?
Related learning recommendation: python tutorial

Python's method of doing mathematical function problems;

1. After opening the CMD command line, let's look at a function for squaring. As shown in the figure below, we can use pow to calculate the power of a certain number.

2. Next, we can use abs function to find the absolute value of a certain number, as shown in the figure below.

3. When we encounter decimals, we often need to abandon the decimal part and use integers directly, so we can use the floor function, but it is wrong to use it directly, as shown in the following figure.

4. At this time, we need to import the math module, because the floor function is in the math module, as shown in the following figure.

5. Next, we will use the square root function sqrt in the mathematical function, as shown in the figure below.

6. Finally, when applying the mathematical function, we can directly assign the initial value to a variable and then call the variable directly, as shown in the figure below.