【问题标题】:Python - While loopPython - While 循环
【发布时间】:2017-10-05 17:01:48
【问题描述】:

我正在尝试制作一个程序,要求客户输入他们想购买的商品数量。然后该程序会找到小计和含税总价。我对如何添加一个while循环感到困惑,这样它会根据用户放置的物品数量不断询问物品的价格,然后它将所有物品加在一起。

【问题讨论】:

    标签: python-3.x while-loop range


    【解决方案1】:

    您必须添加您尝试过的内容以及您遇到的问题。这是一个伪代码开始。

    read the number of items as num
    initialise total to zero
    while num > 0:
        read the price of the each item as price
        calculate the tax and add it to price
        add the taxed price of each item to total
        decrement num
    print sum
    

    【讨论】:

      猜你喜欢
      • 2014-11-02
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-19
      • 2014-05-30
      • 1970-01-01
      相关资源
      最近更新 更多