Summary

Summary of the math library in Python.

2 min read |241 words
March 18, 2026

Summary of Math Library in Python

The math library in Python provides various mathematical functions and constants. Here are some commonly used functions and constants:

Sum of Elements

You can sum elements in a list using the built-in sum() function:

numbers = [1, 2, 3, 4, 5]
total = sum(numbers)
print(total)  # Output: 15

Maximum Value

To find the maximum value in a list, you can use the max() function:

numbers = [1, 2, 3, 4, 5]
maximum = max(numbers)
print(maximum)  # Output: 5

Minimum Value

To find the minimum value in a list, you can use the min() function:

numbers = [1, 2, 3, 4, 5]
minimum = min(numbers)
print(minimum)  # Output: 1

Absolute Value

To get the absolute value of a number, you can use the abs() function:

number = -5
absolute_value = abs(number)
print(absolute_value)  # Output: 5

Power

To calculate the power of a number, you can use the pow() function or the exponent operator **:

base = 2
exponent = 3
power = pow(base, exponent) # 2 ^ 3 = 8
print(power)  # Output: 8

# Using exponent operator
power = base ** exponent
print(power)  # Output: 8