import random class Person: """ A class to represent a person. Attributes ---------- name : (str) name of the person shirt_color : (str) the color of their shirt Methods ------- get_string_color(): Returns the color of the shirt the person is wearing get_name(): Returns the name of the person change_shirt_(): Changes their shirt color to a random choice """ def __init__(self, persons_name, shirt_color): """ Creates a person and gives them a name and a color for their shirt :param persons_name: (str) the name of the person :param shirt_color: (str) the color of the shirt of the perso """ self.name = persons_name self.shirt_color = shirt_color def get_shirt_color(self): """ Returns the color of the shirt the person is wearing :return: (str) the color of the shirt the person is wearing """ return self.shirt_color def get_name(self): """ Returns the name of the person :return: (str) the name of the person """ return self.name def change_shirt(self): """ Changes their shirt color to a random choice :return: (None) """ colors = ["blue", "red", "green", "funny"] self.shirt_color = random.choice(colors) def __str__(self): """ Returns string representation of rectangle :return: (str) "Name", wearing a "color shirt" shirt """ return self.name + ", wearing a " + self.shirt_color + \ " shirt" def main(): # creating two objects using the Person class p1 = Person("Teran", "blue") p2 = Person("Grace", "green") for i in range(1, 8): print("-" * 10) print("Day " + str(i)) print(p1) print(p2) if p1.get_shirt_color() == p2.get_shirt_color(): print(p1.get_name() + " and " + p2.get_name() + \ " are wearing the same shirt color!") # print a blank line print() p1.change_shirt() p2.change_shirt() if __name__ == "__main__": main()