def cal():
global total
box = random.choice(['石头','黄金','钻石'])
if box =='石头':
total = total +20
elif box =='黄金':
total = total +5656
else :
total = total + 234
print(total)
cal()
import random
total = 0
def cal():
global total
s = ['石头', '黄金', '钻石', '狗骨头', '陈校长']
box = random.choice(s)
if box=='石头':
total+=20
elif box=='黄金':
total+=100
elif box =='钻石':
total += 500
elif box =='狗骨头':
total -= 20
else:
total *= 2
print(total)
import random
total = 0
def cal():
global total
s = ['石头', '黄金', '钻石', '狗骨头', '陈校长']
box = random.choice(s)
if box=='石头':
total+=20
elif box=='黄金':
total+=100
elif box =='钻石':
total += 500
elif box =='狗骨头':
total -= 20
else:
total *= 2
print(total)
import random
total=0
def cal():
global total
box=random.choice(["石头","狗骨头","黄金","钻石"])
if box=="石头":
total=total+20
elif box == "狗骨头":
total=total-20
elif box == "黄金":
total = total+100
else:
total = total+500
cal()
print(total)
import random
total = 0
def cal():
global total
box = random.choice(['石头','黄金','钻石','狗骨头'])
if box == '石头':
total += 20
elif box == '黄金':
total += 100
elif box == '狗骨头':
total -= 20
else:
total += 500
return total
print(cal())
import random
def cal():
global total
total = 0
ore_list = ['石头','黄金','钻石','狗骨头'
box = random.choice(ore_list)
if box == '狗骨头':
total -= 20
elif box == '石头':
total += 20
elif box == '黄金':
total += 100
else:
total += 500
def cal():
global total
box = random.choice(['石头','黄金','钻石'])
if box == '石头':
total = total +20
elif box == '黄金':
total = total +100
else:
total = total +500
import random #使用random模块
total = 0 #设置变量
def cal(): #创建函数
global total #设置为全局变量
box = random.choice(['石头', '钻石', '黄金']) #创建一个列表并随机选择一个
if box == '石头': #判断如果是石头
total = total + 20 #那么变量total加20
elif box == '黄金 ': #判断如果是黄金
total = total + 100 #那么变量total加100
else: #除非(也只有钻石了)
total = total + 500 #那么变量total加500
cal() #使用函数
print(total) #打印变量
def cal():
global total
box = random.choice(['石头','黄金','钻石'])
if box == '石头':
total = total + 20
elif box == '黄金':
total = total + 100
else:
total = total + 500
cal()
print(total)
def cal():
global total
box = random.choice(['石头','黄金','钻石'])
if box == '石头':
total = total +20
elif box == '黄金':
total = total +100
else:
total = total +500