我正在用python解决一个问题,我不明白拼写和问题本身。任务是英文的,翻译者不知何故没有清醒地翻译,或者在我看来,任务本身:
填空使 is_power_of 函数返回数字是否是给定基数的幂。注意:base 假定为正数。提示:对于返回布尔值的函数,您可以返回比较结果。
这是向我提出的代码(所有 __ 值得放东西的地方):
def is_power_of(number, base):
# Base case: when number is smaller than base.
if number < base:
# If number is equal to 1, it's a power (base**0).
return __
# Recursive case: keep dividing number by base.
return is_power_of(__, ___)
print(is_power_of(8,2)) # Should be True
print(is_power_of(64,4)) # Should be True
print(is_power_of(70,10)) # Should be False
我不明白该怎么做,请帮忙
试试这样: