Built-in Math Functions

Python provides a number of important built-in functions that we can use without needing to provide the function definition. In this section, we will learn about some of the built-in math functions using that you can perform mathematical tasks on numbers.

The max() and min() functions give us the largest and smallest values in a list, respectively:

x = min(20, 10, 50, 25)		#x = 10
y = max(20, 10, 50, 25)		#y = 50

The abs() function give us the absolute(positive) value of number:

x = abs(-34)		         #x = 34
y = abs(90)			         #y = 90

The pow(a, b) function give us the value of a raised to the power of b (ab):

x = pow(3,4)		        #x = 81


Let’s put it all together! Let’s see if we can create a program that takes 5 numbers from the user and prints the value of minimum of those numbers raised to the power of maximum. For example, given the number 2,7,4,11,9, return 211.