Python类,该类生成人口的随机性别(M/F),并基于n将其分配给社区
人口数量=30
示例人口计数为30(成人、老年人、儿童)
年龄分布成人50%,儿童30%,年龄20%
社区数据
Community_num Community_name Community_polygon Community_population
301 new york Mutipolgon([]) 10
303 JFK Mutipolgon([]) 10
304 River side Mutipolgon([]) 10
预料之外
Community_num Community_name Community_polygon Community_population Gender Age Age_Group
301 new york Mutipolgon([]) 10 F 27 Adult
301 new york Mutipolgon([]) 10 M 27 Adult
301 new york Mutipolgon([]) 10 M 10 Kids
301 new york Mutipolgon([]) 10 M 50 Old
代码尝试
def GeneratePeople(time, n):
people = [None] * n
for i in range(0,n):
people[i] = Person(Gender.Male, 30, time)
return people
我有基本的,但我需要帮助
年龄
kids - below 15
adult - above 15 to 45
old - 45 above
有一种方法可以做到这一点:
结果:
相关问题 更多 >
编程相关推荐