Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I WANT CODE TO PRODUCE THE SAME OUTPUT AS THE IMAGE below Given a base Plant class and a derived rlower class, write a program

I WANT CODE TO PRODUCE THE SAME OUTPUT AS THE IMAGE below image text in transcribed
image text in transcribed
image text in transcribed
Given a base Plant class and a derived rlower class, write a program to create a list called my_garden. Store objects that belong to the plant class or the Flower class in the list. Create a function called print list 0 , that uses the print info0 instance methods defined in the respective classes and prints each element in my_garden. The program should read plants or flowers from input (ending with-1), add each Plant or F lower to the my_garden list, and output each element in my_garden using the print info0 function. Note: A ist can contain different data types and also different objects. Ex. If the input is: plant Splrea 10 flower Hydrangea 30 false 111 ae flower Rose 6 false white plant Mint 4 1 the output is: Plant I Information: Plant name: spirea Cost: 10 Plant 2 Information: Plant name: Hydrangea Coat: 30 Annual: false Color of floverat islae Plant 3 Information: Plant name: rose Cont: 6 Annual: false Color of flowera: White Plant 4 Informationt Plant name: Mint Cost: 4 T000: Define the print list() function that prints a list of plant (or flower) objects if __name_ = "_main__" : * TOO0: Declare a list called my_garden that can hold object of type plant user_string = input( ) while user_string 1=1 : \# Tooo: Check if input is a plant or flower \# Split the user_string input into variables - plant_name, plant_cost, color_of_flowers, is_ar Store as a plant object or flower object Add to the list my-garden user_string = input() TO00: Call the print_list() function to print my_garden plant spirea 10 flower Hydrangea 30 false 11 lac flower Rose 6 false white plant Mint 4 1 Plant 1 Information: Cost: 10 Plant 2 Information: Cost: 30 Annual: False Color of flowers: 11 fac Plant 3 Information: Plant name: Rose Cost: 6 Annual: False Color of flowers: white Plant 4 Information: Plant name: Mint: Cost: 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

What is electric dipole explain with example

Answered: 1 week ago

Question

What is polarization? Describe it with examples.

Answered: 1 week ago

Question

Determine the roles of spatial layout and functionality.

Answered: 1 week ago