diff --git a/func.py b/func.py new file mode 100644 index 0000000..23eda8c --- /dev/null +++ b/func.py @@ -0,0 +1,26 @@ +def new_input(): + total = [] + while True: + money= input("请输入:") + if money== 'q': + break + else: + try: + money=int(money) + except: + print("请重新输入一个数字") + else: + total.append(money) + 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 diff --git a/sjx666..py b/sjx666..py new file mode 100644 index 0000000..491357d --- /dev/null +++ b/sjx666..py @@ -0,0 +1,9 @@ +import sjx666 + + + +data=func.new_input() +score=func.sum() + + +print("这位选手的总分为"+str(score)) diff --git a/sss6666.py b/sss6666.py new file mode 100644 index 0000000..20d0e24 --- /dev/null +++ b/sss6666.py @@ -0,0 +1,9 @@ +import func + + + +data=func.new_input() +score=func.sum() + + +print("这位选手的总分为"+str(score)) \ No newline at end of file