Sépération du code
This commit is contained in:
20
python/planets.py
Normal file
20
python/planets.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import random
|
||||
import pl_stat
|
||||
|
||||
def generate_planet():
|
||||
planet_type_generation = random.choice(list(pl_stat.planet_type.keys()))
|
||||
planet_name = random.choice(pl_stat.planet_name_prefix) + random.choice(pl_stat.planet_name_sufix)
|
||||
planet_population_people = random.choice(pl_stat.planet_population_type)
|
||||
planet_population_number = pl_stat.planet_type[planet_type_generation]["population"] * random.randrange(5, 15) / 10
|
||||
|
||||
planet_description = (f"Planète : {planet_name}\nType : {planet_type_generation}\nPopulation : \n {planet_population_number} milliards\n Majoritairement {planet_population_people}")
|
||||
return planet_description
|
||||
|
||||
def planet_loop(number):
|
||||
count = 0
|
||||
while count < number:
|
||||
planet = generate_planet()
|
||||
print("\n" + planet + "\n\n------------------------------")
|
||||
count += 1
|
||||
|
||||
planet_loop(5)
|
||||
Reference in New Issue
Block a user