我满足这些要求吗?
((MIT OCW Comp Sci教科书简介-手指锻炼)
编写一个程序,要求用户输入整数并打印两个整数,分别是root和pwr,这样0 我的答案one_user_input = float(raw_input("Enter a number: "))
def check_nth_root(x):
for nth_root in range(1, 6):
nth_root = float(nth_root)
calculation = one_user_input ** (1.0 / nth_root)
x = one_user_input % calculation
x = round(x, 9)
if x % nth_root == 0:
print "Root {} & Power {}".format(calculation, nth_root)
else:
print "Root and power pair, doesn't exist"
check_nth_root(one_user_input)
如果答案是在python3中,则在使用print()时需要带括号。