Commit e9f63d83 by BellCodeEditor

auto save

parent 23cf2c63
def diancan():
def diancan():
def diancan():
total = []
while True:
unit= input('请输入(q退出):')
unit= input("请输入:")
if unit== 'q':
break
else:
try:
unit = int(unit)
unit=int(unit)
except:
print("请重新输入一个数字")
print("输入的不是价格")
else:
total.append(unit)
return total
def sum(b): # 计算价钱的函数 b是形参 也就是上边刚才输入的列表
w=0 #计算累加和的变量
for i in b: #遍历b列表
w+=i #依次计算列表中的价格
return w #返回w
a=diancan() #a是diancan函数中的列表
e=sum(a) #给sum函数传入实参a也就是价格列表
print(e) #输出总共的价格
def sum(money):
count = 0
for i in money:
count = count + i
return count
a=diancan()
b=sum(a)
print(b)
\ No newline at end of file
import 返回
import time
import 返回
a=返回.diancan()
b=返回.sum()
\ No newline at end of file
import time
i=0
while True:
i+=1
print(i)
time.sleep(1)
import 返回
import 函数返回值 #只能导入以中英文命名的文件
import 返回
a=返回.diancan()
b=返回.sum()
import 函数返回值 #只能导入以中英文命名的文件
a=函数返回值.diancan()
b=函数返回值.sum()
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