Commit 55b2a082 by BellCodeEditor

auto save

parent 7eaed43a
Showing with 33 additions and 0 deletions
import div
#调用自定义的输入函数,实现分数输入的功能
data = div.new_input()
#调用自定义函数的求和函数,计算需要支付的总价
score = div.sum(data)
print("这位选手的总分数为:"+str(score))
\ No newline at end of file
def new_input():
total = []
while True:
unit = input("请输入价格(输入q程序结束):")
if unit=="q":
break
else:
try:
unit = int(unit)
except:
print("请您输入一个数字!")
else:
total.append(unit)
finally:
print("-"*30)
return total
#定义新函数计算总价
def sum(money):
count = 0
for i in money:
count = count+i
return count
price = new_input()
pay = sum(price)
print("您本次共消费了"+str(pay)+"亿元,您是微信、现金还是刷卡,本店不开发票!")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment