Skip to content

Instantly share code, notes, and snippets.

@luckydenis
Created February 16, 2023 18:43
Show Gist options
  • Save luckydenis/cd0bf13edc26f66096c9e9edd870349a to your computer and use it in GitHub Desktop.
Save luckydenis/cd0bf13edc26f66096c9e9edd870349a to your computer and use it in GitHub Desktop.
import random
class Increment:
def __init__(self, age):
self.count = 0
self.age = age
def up_count(self):
self.count += 1
def __str__(self):
return 'Количество людей в возрасте ' + str(self.age) + ' равно: ' + str(self.count)
class People:
def __init__(self):
self.people = dict()
def add_age(self, age):
if age not in self.people:
self.people[age] = Increment(age=age)
self.people[age].up_count()
people = People()
people_age = []
for i in range(1000000):
age = random.randint(1, 100)
people_age.append(age)
for i in range(len(people_age)):
people.add_age(people_age[i])
for age_of_human in people.people:
print(people.people[age_of_human])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment