代码拉取完成,页面将自动刷新
#微信发红包,金额随机,人数随机待设定,所以这两个因素可以作为变量来设置
#金额用money
#人数用people
#先定义一个函数,随机分配的方法函数
#思路:设定主程序,然后根据题目要求进行修改
#随机分配程序,主程序
import random
def people_shuffle(money,people):
result=[]
max_money=money//people*2
for i in range(people):
if money>1:
m=random.randint(1,min(money,max_money))
else:
break
money-=m
result.append(m/100)
return result
#调取函数用,基本没有问题
people=int(input('Please set the redpocket number:'))
money=int(input('Please set the red number:')*100)
print(people_shuffle(money,people))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。