diff --git a/1.py b/1.py new file mode 100644 index 0000000..6dd6cc8 --- /dev/null +++ b/1.py @@ -0,0 +1,4 @@ +import func +data=func.new_input() +score=func.sum(data) +print('这位选手的总分分数为:'+str(score)) \ No newline at end of file diff --git a/__pycache__/func.cpython-37.pyc b/__pycache__/func.cpython-37.pyc new file mode 100644 index 0000000..5577ff8 Binary files /dev/null and b/__pycache__/func.cpython-37.pyc differ diff --git a/func.py b/func.py new file mode 100644 index 0000000..a0f1948 --- /dev/null +++ b/func.py @@ -0,0 +1,24 @@ +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('======================') + 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