Trusted answers to developer questions

Maria Elijah

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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

- For
`pow(x, y)`

return value will be $x^y$. - For
`pow(x, y, z)`

return value is equal to $x^y$ % 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("--------------------------------")

- Line 2–3: We create variables
`x`

and`y`

and assign values to them. - Line 5: We pass the values to the
`pow()`

function and store the result in a new variable called`result`

. - Line 6–7: We display values of
`x`

and`y`

. - Line 9: We display the result of
`pow(x,y)`

. - Line 13: We create the variable
`z`

and assign a value to it. - Line 14: We display the value of
`z`

. - Line 15: We pass all three values to the
`pow()`

function and store the result in a new variable called`result1`

. - Line 16: We display the result of
`pow(x,y,z)`

.

RELATED TAGS

python

communitycreator

CONTRIBUTOR

Maria Elijah

Grokking Modern System Design Interview for Engineers & Managers

Keep Exploring

Related Courses