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(gebDict)
|
||||||
print(gestDict)
|
print(gestDict)
|
||||||
print(bevAnzahl)
|
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)):
|
for i in range(int(bevAnzahl)):
|
||||||
gender = 1
|
gender = 1
|
||||||
@ -185,20 +191,10 @@ if __name__ == '__main__':
|
|||||||
gender = 0
|
gender = 0
|
||||||
age = random.randint(0, 101)
|
age = random.randint(0, 101)
|
||||||
|
|
||||||
bdl = ""
|
bdl = random.choices(bdls, weights)[0]
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
Population.append(Mensch(age, gender, bdl))
|
Population.append(Mensch(age, gender, bdl))
|
||||||
|
|
||||||
Simulation = Simulation(Population)
|
Simulation = Simulation(Population)
|
||||||
Simulation.simulate()
|
Simulation.simulate()
|
||||||
|
|
||||||
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
|
|
||||||
|
Loading…
Reference in New Issue
Block a user