Question: Define a Grandchild Class which contains: A static Class variable to count the number of objects created. Three instance variables, name, age and favorite color.

Define a Grandchild Class which contains:
A static Class variable to count the number of objects created.
Three instance variables, name, age and favorite color.
An __init__ method
A __str__ method to print the values of the objects instance variables.
An isOlder instance method to compare the ages of two objects.
In main write code to test your class.
Create three objects of the Grandchild class.
Print the values of each instance variable of each object to the screen.
Print only the age of each of the three Grandchild objects to the screen.
Print to the screen the value of your static Class variable to show how many objects
have been instantiated.
Create a list of 20 more Grandchild objects using random names, random ages and
random favorite colors.
Find the average age of all of the 20 Grandchildren that are in the list.
Print the result to the screen.
Print to the screen the value of your static Class variable again to show how many
objects have now been instantiated.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!