Commit 5c281dc3 by BellCodeEditor

save project

parent cd6ca711
Showing with 55 additions and 17 deletions
# 玩家出拳 def new_input():
player=input("请出拳(石头/剪刀/布):") total = []
print("玩家出拳:"+player) while True:
import random unit=input('请输入单价(q退出):')
list=["石头","剪刀","布"] if unit=='q':
computer=random.choice(list) break
print("电脑出拳:"+computer) else:
if player in list: try:
if player==computer: unit= int(unit)
print("平局") except:
elif(player=="石头" and computer=="剪刀") or (player=="剪刀" and computer=="布") or (player=="布" and computer=="石头"): print("请重新输入")
print("恭喜,你赢了") else:
else: total.append(unit)
print("很遗憾,你输了") finally:
else: print("-"*30)
print("输入错误") print(total)
\ No newline at end of file def sum(money):
count=0
for i in money:
count=count+i
return count
print=new_input
pay=sum_price
print("一共消费了"+str(pay))
\ No newline at end of file
import func
data=func.new_input()
score=func.sum(data)
print("选手分数是+str(score)")
\ No newline at end of file
def new_input():
total = []
while True:
unit=input('请输入单价(q退出):')
if unit=='q':
break
else:
try:
unit= int(unit)
except:
print("请重新输入")
else:
total.append(unit)
finally:
print("-"*30)
print(total)
def sum(money):
count=0
for i in money:
count=count+i
return count
print=new_input
pay=sum_price
print("一共消费了"+str(pay))
\ 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