diff --git a/__pycache__/func.cpython-37.pyc b/__pycache__/func.cpython-37.pyc new file mode 100644 index 0000000..4ada5a3 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..2b231ad --- /dev/null +++ b/func.py @@ -0,0 +1,22 @@ +def new_input(): + total = [] + while True: + unit= input("请输入:") + if unit== 'q': + break + try: + a= int(unit) + except: + print('请输入一个整数!') + else: + total.append(a) + #print(total) + return total +#b=new_input() +def sum(list1): + sum=0 + for i in list1: + sum=sum+i + return sum +#c=sum(b) +#print(c) \ No newline at end of file diff --git a/swim.py b/swim.py new file mode 100644 index 0000000..a359bab --- /dev/null +++ b/swim.py @@ -0,0 +1,5 @@ +import func + +data=func.new_input() +score=func.sum(data) +print('该选手的总分为:',score) \ No newline at end of file