How can the large_power function work for values other than 5000?

Question

For this exercise, the large_power function checks against the value 5000. How can the function be modified to work against other values?

Answer

The large_power() function can be modified to accept another parameter to be used as part of the if to perform the check. This parameter can replace the hardcoded value of 5000. In this example. the function is modified to accept a new parameter named limit.

def large_power(base, exponent, limit):
  if base ** exponent > limit:
8 Likes