In python, we use the pow function to return the power of a given number.
pow(x, y, z)
x: This represents the base.y: This represents the exponent.z: This represents the modulus. This parameter is optional.Note: pow(x, y, z) = x**y % z
pow(x, y) return value will be .pow(x, y, z) return value is equal to % z.The following code shows how to use the pow() in python:
# create variable x, yx = 4y = 8# store resultresult = pow(x, y)print(f"Value of x: {x}")print(f"Value of y: {y}")print(f"Result for pow(x,y): {result}")# create variable zprint("--------------------------------")z = 5print(f"Value of z: {z}")result1 = pow(x,y,z)print(f"Result for pow(x,y,z): {result1}")print("--------------------------------")
x and y and assign values to them.pow() function and store the result in a new variable called result.x and y.pow(x,y).z and assign a value to it.z.pow() function and store the result in a new variable called result1.pow(x,y,z).