diff --git a/1.py b/1.py new file mode 100644 index 0000000..ccb0786 --- /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..8a3f0f1 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..e5d9b49 --- /dev/null +++ b/func.py @@ -0,0 +1,26 @@ +def new_input(): + total = [] + while True: + unit = input("请输入:") + if unit == 'q': + break + else: + try: + unit = int(unit) + except: + print("请重新输入一个数字") + else: + total.append(unit) + finally: + print("-"*30) + return total + +def sum(moeny): + count = 0 + for i in moeny: + count = count + i + return count + +price = new_input() +pay = sum(price) +#print("你消费了"+str(pay)+"扫码还是现金") \ No newline at end of file