All MicroEvals
Complete the following Python function: ```python def modp(...
Create MicroEval
Header image for Complete the following Python function:

```python
def modp(...

Complete the following Python function: ```python def modp(...

Prompt

Complete the following Python function: ```python def modp(n: int, p: int): """Return 2^n modulo p (be aware of numerics). >>> modp(3, 5) 3 >>> modp(1101, 101) 2 >>> modp(0, 101) 1 >>> modp(3, 11) 8 >>> modp(100, 101) 1 """ ```

Answer guidance

Canonical solution (function body): ret = 1 for i in range(n): ret = (2 * ret) % p return ret

Drag to resize
Drag to resize