编写一个程序,输入为整数 user_num 和 x,输出 user_num 除以 x 的 3 次

新手上路,请多包涵

Write a program using integers user_num and x as input, and output user_num divided by x three times.

前任:

 If the input is:
2000
2

然后输出是:

 1000 500 250
 Note: In Python 3, integer division discards fractions. Ex: 6 // 4 is 1 (the 0.5 is discarded).

这是我的代码:

 user_num = int(input())
x = int(input())

for i in range(3):
    user_num/= x
    print (int(user_num), end=' ')

我的输出与 s 的图片有

我只需要添加一个结束行,输出为 250。

原文由 Adam Dickenson 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 320
1 个回答
''' Type your code here. '''
user_num = int(input())
x = int (input())

i = 0
while i <= 2 :
    if i <= 1:
        user_num //= x
        print(user_num, end= " ")
        i += 1
    elif i == 2:
        user_num //= x
        print(user_num)
        i += 1

原文由 user19202665 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题