首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python - While循环

Python - While循环
EN

Stack Overflow用户
提问于 2017-10-05 04:42:38
回答 1查看 32关注 0票数 0

我试图制作一个程序,要求客户输入他们想要的商品数量,purchase.The程序,然后找到小计和总价格与税收。我对如何添加while循环感到困惑,因为它会根据用户放置的项目数量不断询问商品的价格,然后再将所有的项目加在一起。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-05 09:01:48

你必须加上你尝试过的东西和你被困的地方。下面是一段伪代码。

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46577979

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档