Hacks

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age
#identifies how many years left until the person is 100
    def years_until_100(self):
        return 100 - self.age
#creating additional class registry which puts all Person together
class PersonRegistry:
    def __init__(self):
        self.people_list = []
        self.people_dict = {}

    def add_person(self, person):
        self.people_list.append(person)
        self.people_dict[person.name] = person.age

    def print_people(self):
        for person in self.people_list:
            print(f"Name: {person.name}, Age: {person.age}, Years until 100: {person.years_until_100()}")

    def oldest_person(self):
        if not self.people_dict:
            print("No people in the registry.")
            return

        oldest_name = max(self.people_dict, key=self.people_dict.get)
        print(f"The oldest person is: {oldest_name}, Age: {self.people_dict[oldest_name]}")

# Example usage:

# Creating a PersonRegistry
registry = PersonRegistry()

# Adding people to the registry
registry.add_person(Person("Sergi", 15))
registry.add_person(Person("Abdullah", 14))
registry.add_person(Person("Lincoln", 15))

# Printing people from the registry
print("People from the registry:")
registry.print_people()

# Printing the name of the oldest person in the registry
print("\nThe oldest person in the registry:")
registry.oldest_person()

People from the registry:
Name: Sergi, Age: 15, Years until 100: 85
Name: Abdullah, Age: 14, Years until 100: 86
Name: Lincoln, Age: 15, Years until 100: 85

The oldest person in the registry:
The oldest person is: Sergi, Age: 15