From 23f64403071712622f747a223a17e8d10f010e9f Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sun, 4 Sep 2022 18:07:37 +0800 Subject: [PATCH] save project --- func.py | 31 +++++++++++++++++++++++++++++++ sb.py | 4 ++++ 2 files changed, 35 insertions(+) create mode 100644 func.py create mode 100644 sb.py diff --git a/func.py b/func.py new file mode 100644 index 0000000..ed30b9c --- /dev/null +++ b/func.py @@ -0,0 +1,31 @@ +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 a in money: + count = count + int(a) + return count + + +price=new_input() +pay=sum(price) +print("您一共消费了"+str(pay)+"¥") + diff --git a/sb.py b/sb.py new file mode 100644 index 0000000..59849e5 --- /dev/null +++ b/sb.py @@ -0,0 +1,4 @@ +import func +sbzgh=func.new_input() +sb=func.sum(sbzgh) +print(int(sb)) \ No newline at end of file -- libgit2 0.25.0