Question
First, create a python class called ? Person ? that will store the information about a person. Be sure to store the following attributes: ?
First, create a python class called ?Person? that will store the information about a person. Be sure to store the following attributes:
? first_name? - string
? last_name ?- string
? age ?- integer
? address? - string
? phone_number? - string
? email? - string
? interests - ?a list of strings (each string is a short description of something they
are interested in)
As a part of this class, write an ?__init__?function in your person class that that has a parameter for each class attribute and sets them properly when a new person object is created. Once this is done, write a ?__str__? function that will convert some or all of the attributes in the person class into a string suitable to be printed to the screen. Examples of both of these functions were given in class.
Outside of your class, create a few new person objects and store them in a list. Then write a for loop to iterate over these person objects and print them out.
Outside of your ?Person? class write a function called ?over_age? that takes a list of person objects and an integer as its parameters. This function will iterate over the list of person objects and print out each person that is over the age provided.
Create a function inside your ?Person ?class called a? dd_interest?. This function will take string as its only parameter. This function will add the interest provided to the list of interests within the person object only if it is not already in the list. If the interest is in the list this function will do nothing. ?HINT: ?since you are writing this function in the person class, you will have to use the self? variable to access and change the interests variable, as shown in class.
Create a function inside your ?Person ?class called r? emove_interest?. This function will take string as its only parameter. This function will remove the interest provided from list of interests within the person object only if it is already in the list. If the interest is not in the list this function will do nothing.
Create a function outside of your person class called ?something_in_common?. This function will take two person objects as parameters. It will then compare the interests of the two person objects. The function will return a boolean: it will return ?True? is the two person objects have an interest in common and will return ?False? if they dont.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started