Countries distributed with random.choice() - more comprehensible code style
This commit is contained in:
parent
8e2d6b008a
commit
43053d7e32
20
main.py
20
main.py
@ -177,7 +177,13 @@ if __name__ == '__main__':
|
||||
print(gebDict)
|
||||
print(gestDict)
|
||||
print(bevAnzahl)
|
||||
print(random.random())
|
||||
|
||||
bdls = []
|
||||
weights = []
|
||||
for key in bevDict.keys():
|
||||
bdls.append(str(key))
|
||||
weights.append(int(bevDict[key]) * Populationsfaktor / int(bevAnzahl))
|
||||
|
||||
|
||||
for i in range(int(bevAnzahl)):
|
||||
gender = 1
|
||||
@ -185,20 +191,10 @@ if __name__ == '__main__':
|
||||
gender = 0
|
||||
age = random.randint(0, 101)
|
||||
|
||||
bdl = ""
|
||||
randBdl = random.random()
|
||||
BdlCount = 0
|
||||
for key in bevDict.keys():
|
||||
BdlCount += int(bevDict[key])
|
||||
checkWlsk = (BdlCount*Populationsfaktor)/int(bevAnzahl)
|
||||
if(randBdl < checkWlsk):
|
||||
bdl = str(key)
|
||||
break
|
||||
|
||||
bdl = random.choices(bdls, weights)[0]
|
||||
|
||||
Population.append(Mensch(age, gender, bdl))
|
||||
|
||||
Simulation = Simulation(Population)
|
||||
Simulation.simulate()
|
||||
|
||||
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
|
||||
|
Loading…
Reference in New Issue
Block a user