我写了一个代码来显示AP的编号,与输入的编号
的条件相关联P = int(input())
R = int(input())
Q = int(input())
S = 0
Cont = 0
while Cont<=Q:
print("Termo",Cont,"da PA = ",P)
P = P+R
Cont = Cont+1
它工作正常,但在这种情况下,我如何总结AP的所有条款?
答案 0 :(得分:0)
在循环中添加计算的术语。
P = int(input())
R = int(input())
Q = int(input())
S = 0
Cont = 0
while Cont<=Q:
print("Termo",Cont,"da PA = ",P)
S = S + P
P = P+R
Cont = Cont+1
print("Sum:",S)