我想制作一个程序,它将带电并将其变成附加问题
main_number = int(input("Enter the number to be brought to the power "))
power = int(input("Enter the power "))
def get_num_of_final(power,number):
yeet = pow(power,number-1)
print(str(yeet))
return(yeet)
def finall(number,multi):
final = ""
for i in range(multi):
final += str(number)
final += " + "
print(final)
finall(main_number, get_num_of_final(power,main_number))
如果您输入2作为主电源,然后输入3作为电源,您应该得到2 + 2 + 2 + 2,但是您得到2 + 2 + 2 +或数字更大,您得到的结果将比预期的要高得多>
答案 0 :(得分:1)
result = main_number**power
print(f'{"+".join([str(main_number), ]*(result//main_number))} = {result}')
输出 2 + 2 + 2 + 2 = 8
答案 1 :(得分:0)
您使用错误的参数致电pow
;您需要:
yeet = pow(number, power-1)
新输出:
4
2 + 2 + 2 + 2 +