Question: Python Question 11A Write a definition line for a class named State and a one-line doc string that describes what a State is. Write definitions
Python
Question 11A Write a definition line for a class named State and a one-line doc string that describes what a State is. Write definitions for the following methods (functions) in the code for the class: 1. An initialization method. The initialization method should: Take a string parameter, name, and assign it as variable name of the state being created Create a list variable, universities, for the state being created and initialize it to the empty list 2. A method named addUniversity. This method should take the name of a university as a string parameter and add it to the list of universities for a that state. 3. A method named is_home_of. This method should take the name of a university as a string parameter. If the university is in the states list of universities it should return True, otherwise it should return False. Question 11B Assume that the code for the class State (Question 11A) has been saved in a file named state.py. Write code that performs the following tasks (each task takes one line): 1. import the module that defines the class State 2. create a state named New Jersey 3. add universities NJIT and Princeton to New Jersey 4. check whether New Jersey is home of MIT and print the result
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
