问:计算1**1+2**2+3**3+...+n**n
# 方法一 su =0 x = int(input("请输入你想输入的值:")) for i in range(1,x+1): su +=i**i print(f"最后的值为:{su}") # 方法二 def Ayue(n): return n**n m = int(input("请输入你想要计算的值:")) x = 0 i = 1 while(i<=m): x += Ayue(i) i+=1 print(f"输出结果是:{x}")
标签:10,python,练习,su,int,input,输入 From: https://www.cnblogs.com/ayue6/p/17787104.html