Skip to content

Latest commit

 

History

History
47 lines (30 loc) · 1.97 KB

File metadata and controls

47 lines (30 loc) · 1.97 KB

Instructions append

Python Implementation

The tests for this exercise expect your program to be implemented as a Garden class in Python. If you are unfamiliar with classes in Python, classes from the Python docs is a good place to start.

Your class should implement a method called plants, which takes a student's name as an argument and returns the list of plant names belonging to that student.

Constructors

Creating the example garden

[window][window][window]
VRCGVVRVCGGCCGVRGCVCGCGV
VRCCCGCRRGVCGCRVVCVGCGCV

would, in the tests, be represented as Garden("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV").

To make this representation work, your class will need to implement an __init__() method. If you're not familiar with __init__() or constructors, class and instance objects from the Python docs gives a more detailed explanation.

Default Parameters

In some tests, a list of students is passed as an argument to __init__(). This should override the twelve student roster provided in the problem statement. Both of these statements need to work with your __init__() method:

# Make a garden based on the default 12-student roster.
Garden("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV") 

# Make a garden based on a 2-student roster.
Garden("VRCC\nVCGG", students=["Valorie", "Raven"]) 

One approach is to make the student list a default argument; the Python docs describe default parameters in depth while explaining function definitions.