随机导入 导入数学
def RoTMG_HP_Function(): initial = 0 for x in range(19): initial + =(random.randint(-5,5)) 返回初始
'''印刷(RoTMG_HP_Function())'''
def Roll_Simulator(x): x = int(输入("输入模拟次数。")) RollsList = [] 对于范围(x)中的i: RollsList.append(STR(RoTMG_HP_Function()))
'''#Miscellaneous code, just test case, not relevant
for i in range (-95,96):
Listcount = 0
for j in range (200):
if int(Rollslist[j]) == i:
Listcount +=1
if Listcount > 0:
print('The roll of ' + str(i) + ' appears ' + str(Listcount) + ' times. ')''''
LifepotExpenditure = 0
for i in range (-19,20):
Listcount = 0
RollsLower = 0
for j in range (x):
if math.floor(int(RollsList[j]) // 5) == i:
Listcount +=1
elif math.floor(int(RollsList[j]) // 5) < i:
RollsLower += 1
if Listcount > 0:
print('Differential of ' + str(i) + ': ' + str(Listcount) + '. The probability of this is ' + str(float(100*Listcount / x)) + '%. The probability of a worse roll is ' + str(float(100*RollsLower / x)) + '%.')
LifepotExpenditure += i*(Listcount)
AverageLifepotExpenditure = float(19.0) - float(LifepotExpenditure / x)
print('\n' + 'On average, you will spend ' + str(AverageLifepotExpenditure) + ' lifepots to max life.')
打印(Roll_Simulator(21))
答案 0 :(得分:0)
这一行
print('The roll of ' + str(i) + ' appears ' + str(Listcount) + ' times. ')''''
最后还有一个额外的逗号,只需删除它