为了账号安全,请及时绑定邮箱和手机立即绑定

我不明白为什么需要用 'tr' 替换 'pt',如果我不这样做,它就不起作用

我不明白为什么需要用 'tr' 替换 'pt',如果我不这样做,它就不起作用

斯蒂芬大帝 2023-03-16 15:40:49
pt = int(input('First Term: '))rz = int(input('Ratio: '))tr = ptpc = 1while pc <= 10:    print('{}'.format(tr))    tr += rz    pc += 1我不明白为什么需要用 'tr' 替换 'pt',如果我不这样做,它就不起作用
查看完整描述

1 回答

?
函数式编程

TA贡献1807条经验 获得超9个赞

你是这个意思吗?


pt = int(input('First Term: '))

rz = int(input('Ratio: '))

#here removed the variable tr

pc = 1

while pc <= 10:   

    print('{}'.format(pt))

    pt += rz

    pc += 1

这里我刚刚删除了变量 tr。两者都给出相同的输出。


输出:


First Term: 2

Ratio: 4

2

6

10

14

18

22

26

30

34

38

如果您的问题不是这个或没有解决,请发送反馈。


查看完整回答
反对 回复 2023-03-16
  • 1 回答
  • 0 关注
  • 66 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信