Commit 06e50ba1 by BellCodeEditor

save project

parent 6d88eca4
Showing with 47 additions and 0 deletions
try:
age = int(input('你今年几岁了'))
except:
print('要数')
print('~~~~~')
\ No newline at end of file
import random
choices=['石头','砂锅','水']
print('???游戏')
player=input('你出啥')
while (cpayer != '退出'):
computer=random.choice(choices)
print((('你'+player)+'我')+computer)
\ No newline at end of file
def er():
#定义一个列表,用来存放价格
total = []
while True:
#提示用户输入,用unit变量接受输入的值
unit=input('请输入‘按q退出')
if unit=='q':
break
else:
try:
unit=int(unit)
except:
print('请输入一个整数')
else:
total.append(unit)
print(total)
return total
price=er()
print("==========================================")
print(price)
print('我下面开始计算菜单的总价')
'''
思路:
遍历得到列表中的每个值,然后让他们相加
'''
#定义一个变量储存总价
sum=0
for i in price:
sum+=i
print('菜单的总价格为:'+str(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