Question
python question
2. In a file called parks_test.py, test your class definitions created above as follows: • create a Park object • print the P
Sample input/output: Park name: General Park Location: MS Area covered ( 2): 300 Year established: 1963 Cost for 2 days in Ge
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the program below, refer the programs screenshot below for indentation, line number, correctness etc:

The class ProvincialPark and NationalPark are inherited from the base class Park

class Park:

    def __init__(self, name, location, establish, cost_pp=10, area=100):
        self.name = name
        self.cost_pp = cost_pp
        self.area = area
        self.location = location
        self.establish = establish

    def display_cost(self, days=1):
        print("\nCost for ", days, " days in ", self.name, " is $", float(self.cost_pp * days))

    def update_area(self, area=100):
        self.area = area
        print("\nPark name: ", self.name)
        print("Update park area: ", self.area)

    def display(self):
        print("\nPark name: ", self.name)
        print("Location: ", self.location)
        print("Area covered (km^2): ", self.area)
        print("Year established: ", self.establish)


class ProvincialPark(Park):
    def __init__(self, name, location, establish, cost_pp=20, area=200, rating=1):
        super(ProvincialPark, self).__init__(name, location, establish, cost_pp, area)
        self.rating = rating

    def display(self):
        super().display()
        print("Park rating: ", self.rating)

    def update_rating(self, rating):
        self.rating = rating
        print("\nPark name: ", self.name)
        print("Updated rating: ", self.rating)


class NationalPark(Park):
    def __init__(self, name, location, establish, cost_pp=20, area=200, known_for="Nothing"):
        super(NationalPark, self).__init__(name, location, establish, cost_pp, area)
        self.known_for = known_for

    def display(self):
        super().display()
        print("Known for: ", self.known_for)

    def update_known_for(self, known_for):
        self.known_for = known_for
        print("\nPark name: ", self.name)
        print("Updated known for: ", self.known_for)


parks = []
p1 = Park("General Park", "NS", 1963, 5, 300)
parks.append(p1)
p1.display()
p1.display_cost(2)
p1.update_area(400)

p2 = ProvincialPark("Big Park", "NL", 1950, 35, 200, 3)
parks.append(p2)
p2.display()

p3 = ProvincialPark("Small Park", "ON", 1980, 30, 150, 2)
parks.append(p3)
p3.display()

p4 = ProvincialPark("Medium Park", "BC", 1992, 35, 165, 3)
parks.append(p4)
p4.display()

p2.update_rating(1)

p2.display_cost(3)
p3.display_cost(3)


p5 = NationalPark("Gros Morne", "NL", 1973, 40, 1805, "Freshwater Fjords")
parks.append(p5)
p5.display()

p6 = NationalPark("Banff", "AB", 1980, 40, 6641, "Big Lake")
parks.append(p6)
p6.display()

p5.update_known_for("Floating lilies")

print("\nTotal number of Park objects is: ", len(parks))

Screenshots of the program with the output, refer the line numbers:

park.py class Park: 1 2 def init_(self, name, location, establish, cost_pp=10, area=100): self.name = name 4 self.cost_pp = c

park.py print (Updated rating: , self. rating) 37 38 39 class Nationa lPa rk ( Pa rk) : 40 init_( self, name, location, estpark.py parks.append(p1) 57 p1.display) p1.display_cost (2) p1.update_area ( 400 ) 58 59 60 61 p2 = Provincia l Pa rk ( Big

Output:

park Users/i338994/PycharmProj ects/test/venv/bin/pyt hon /Users/i338994/ Pycha rmProjects/test/venv/pa rk. py Park name: GenPark name: Gros Morne Location: NL Area covered (km^2): 1805 Year establis hed : 1973 Freshwater Fjords Known for: Park name:

Please provide a feedback by clicking on the feedback button. In case of any correction, I will provide a comment

Add a comment
Know the answer?
Add Answer to:
python question 2. In a file called parks_test.py, test your class definitions created above as follows:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Code Question# 1 General Instructions Create a class called LawnService that takes in the length...

    Python Code Question# 1 General Instructions Create a class called LawnService that takes in the length and width of a yard, along with the current state of the yard. The currect state can be: poor, acceptable or great. Within this class include a constructor that will assign these values to attributes. Additionally create three methods that will be named and do the following: *DetermineApplication: This method will focus on the lawn status attribute. If the status is poor, the lawn...

  • Zybooks 11.12 LAB*: Program: Online shopping cart (continued) Python 3 is the code needed and this...

    Zybooks 11.12 LAB*: Program: Online shopping cart (continued) Python 3 is the code needed and this is in Zybooks Existing Code # Type code for classes here class ItemToPurchase: def __init__(self, item_name="none", item_price=0, item_quantity=0): self.item_name = item_name self.item_price = item_price self.item_quantity = item_quantity # def __mul__(self): # print_item_cost = (self.item_quantity * self.item_price) # return '{} {} @ ${} = ${}' .format(self_item_name, self.item_quantity, self.item_price, print_item_cost) def print_item_cost(self): self.print_cost = (self.item_quantity * self.item_price) print(('{} {} @ ${} = ${}') .format(self.item_name, self.item_quantity, self.item_price,...

  • about this question 2, I don't know how to do it in C++, can anyone help...

    about this question 2, I don't know how to do it in C++, can anyone help me out??? C 38s. A &X C Solved Get Hon (246) Th (242) A X PowerPo X X endrc Microso odle.concordia.ca/moodle/pluginfile.php/3796501/mod resource/content/1/A4 % 20- %20F2019 pdf COEN 243-Fall 2019 2. (25 marks) Define a class called "House", that represents the information of a house. A House is defined with these attributes: age (int), type (string) (Detached, Semi-Attached, Attached), rooms (int) and cost (double). Functions...

  • Activity: Writing Classes Page 1 of 10 Terminology attribute / state behavior class method header class...

    Activity: Writing Classes Page 1 of 10 Terminology attribute / state behavior class method header class header instance variable UML class diagram encapsulation client visibility (or access) modifier accessor method mutator method calling method method declaration method invocation return statement parameters constructor Goals By the end of this activity you should be able to do the following: > Create a class with methods that accept parameters and return a value Understand the constructor and the toString method of a class...

  • Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In...

    Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In this project, we combine the concepts of Recursion and Merge Sorting. Please note that the focus of this project is on Merging and don't forget the following constraint: Programming Steps: 1) Create a class called Art that implements Comparable interface. 2) Read part of the file and use Merge Sort to sort the array of Art and then write them to a file. 3)...

  • Question 1 For a firm to recognize revenue, it must 1 point Have delivered something to...

    Question 1 For a firm to recognize revenue, it must 1 point Have delivered something to the customer have received at least some cash from the customer be earned and realized/realizable either have received cash or have a signed contract 2. Question 2 Your friend Yong has a company making and selling watches with bands that are customized to match university colors. The business started locally, but now has expanded around the world. His strategy is to sell in bulk...

  • C# - Inheritance exercise I could not firgure out why my code was not working. I...

    C# - Inheritance exercise I could not firgure out why my code was not working. I was hoping someone could do it so i can see where i went wrong. STEP 1: Start a new C# Console Application project and rename its main class Program to ZooPark. Along with the ZooPark class, you need to create an Animal class. The ZooPark class is where you will create the animal objects and print out the details to the console. Add the...

  • 6 MILESTONE 2 (Due in Module 4) MILESTONE 3 (Due in Module 5) MILESTONE 1 (Due in Module 2) 7 9 Instructions Milestone 2 10 12 1. Contribution Margin COGM Schedule .5 Name Choose a price range and ca...

    6 MILESTONE 2 (Due in Module 4) MILESTONE 3 (Due in Module 5) MILESTONE 1 (Due in Module 2) 7 9 Instructions Milestone 2 10 12 1. Contribution Margin COGM Schedule .5 Name Choose a price range and calculate Grooming Create a Cost of Goods Manufactured Sched Location Vision Day Care Mission Bcarding 2. 2. 2. Break-Even Analysis Identify the following Create an Income Statement Calculate the break-even units Revenue will be provided end of week 4 Direct Materials Grooming...

  • 2) prepare the T-accounts. To complete the journal entries, do not forget that you need to...

    2) prepare the T-accounts. To complete the journal entries, do not forget that you need to make the adjusting entries per the descriptions of transactions in the project document. 3) The last tab in the Excel template is for you to prepare the unadjusted trial balance, as well as the adjusted trial balance. Note that you need to enter all the adjustments in the worksheet. 4) The last step of the project is to make the closing entries. You shall...

  • Please write an 1. executive overview of the above case study. 2. in detail, what is...

    Please write an 1. executive overview of the above case study. 2. in detail, what is the critical issue or problem in the above case study. 3. please provide a detailed analysis of the cause of the issue or problem in the above case study. 國connect VIDEO CASE 1 Chobani: Making Greek Yogurt a Household Name Everybody should be able to enjoy a pure, simple cup of yogurt. And that's what Chobani is," says The very first cup for sale...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT