Commit fa33fa37 by BellCodeEditor

save project

parent 8fa3bef5
a=open(r"C:\Users\Windows 10\Desktop\book.txt",'w',encoding='utf-8')
a.write("小兰:12本\n小丽:11本\n李文:9本\n张伟:16本")
a.close()
\ No newline at end of file
import func
c=func.newinput()
p=func.sum(c)
print(p)
\ No newline at end of file
def sum(a):
s=0
for i in a:
s=s+a
return s
def newinput():
total = []
while True:
unit= input("请输入:")
if unit== 'q':
break
else:
try:
unit=int(unit)
except:
print("请输入数字")
else:
total.append(unit)
return total
abc=newinput()
d=sum(abc)
print(d)
\ No newline at end of file
def add (x,y):
z=x+y
print("z的值为:",z)
return z
result=add(1,2)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment