def hello(): S = 0 Low = int(input(‘请最小得币数:‘)) High = int(input(‘请最大得币数:‘)) if High < Low: print (‘最大得币数不能大于最小得币数‘) hello() i = int(input(‘请输入系数:‘)) QS = [Q for Q in range(Low,High + 1)] for Q in QS: S = S +(1/((Q/Low) ** i)) for Q in QS: print(‘得币数为 %s 的概率为: %s‘ % (Q,((1/((Q/Low) ** i))/S))) hello()
原文:https://www.cnblogs.com/xlsxls/p/9190867.html