diff --git a/__pycache__/func.cpython-37.pyc b/__pycache__/func.cpython-37.pyc new file mode 100644 index 0000000..faeae3e 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..1596eaa --- /dev/null +++ b/func.py @@ -0,0 +1,22 @@ +def new_func(): + total = [] + while True: + unit= input("请输入:") + if unit== 'q': + break + else: + try: + unit=int(unit) + except: + print('请输入一个整数') + else: + total.append(unit) + return total +def sum(money): + count=0 + for i in money(): + count=count+i + return count +re=new_func +ply=sum(re) +print('你一共消费了'+ str(ply)+'元') diff --git a/hweuh.py b/hweuh.py new file mode 100644 index 0000000..0cf748a --- /dev/null +++ b/hweuh.py @@ -0,0 +1,4 @@ +import func +date=func.new_func +score=func.sum(date) +print('这位选手的分数为:'+str(score)) \ No newline at end of file