Complete the code to multiply the result by base when exponent is odd.
def fast_power(base, exponent): result = 1 while exponent > 0: if exponent % 2 == 1: result = result * [1] base = base * base exponent = exponent // 2 return result
When the exponent is odd, multiply the current result by the base.
Complete the code to update the exponent by dividing it by 2 using integer division.
def fast_power(base, exponent): result = 1 while exponent > 0: if exponent % 2 == 1: result = result * base base = base * base exponent = [1] return result
Use integer division (//) to halve the exponent for the next iteration.
Fix the error in the base update step to correctly square the base.
def fast_power(base, exponent): result = 1 while exponent > 0: if exponent % 2 == 1: result = result * base base = base [1] base exponent = exponent // 2 return result
To square the base, multiply it by itself using '*'.
Fill both blanks to create a dictionary comprehension that maps numbers to their powers of 2 for numbers less than 5.
powers = {x: 2[1]x for x in range(5) if x [2] 5}Use '**' for exponentiation and '<' to filter numbers less than 5.
Fill all three blanks to create a dictionary comprehension that maps uppercase letters to their ASCII codes if the code is greater than 65.
ascii_map = [1]: ord([2]) for [3] in 'ABCDEF' if ord([2]) > 65}
Use 'letter' as the variable name consistently for keys and in ord() function.