Concept explainers
def calculate_growth_cycle(plant_name):
if(plant_name == "strawberry"):
print("### The life cycle of a strawberry ###\nA seed takes 110 days to reach maturity.")
elif(plant_name == "cucumber"):
print("### The life cycle of a cucumber ###\nA seed takes 76 days to reach maturity.")
elif(plant_name == "potato"):
print("### The life cycle of a potato ###\nA seed takes 120 days to reach maturity.")
else:
print('Your plant is available, please try "strawberry", "cucumber" or "potato"')
Plants Growth Cycle
Learning Objectives
In this lab, you will practice:
- Defining a function to match the given specifications
- Calling the function in your program
- Using if statements (can combine them with dictionaries)
Instructions
For every plant, there is a growth cycle. The number of days that it takes starting from being a seed and ending in being a fruit is what is called the growth cycle. Write a function that takes a plant's name as an argument and returns its growth cycle (in days).
In your program:
-
Input from the user the name of a plant
-
Check if the input is either "strawberry", "cucumber" or "potato", if Yes:
2.1 Call calculate_growth_cycle
2.2. In function calculate_growth_cycle, check over the plant's name:
2.2.1 If strawberry, print "### The life cycle of a strawberry ###" and return 110
2.2.2 If cucumber, print "### The life cycle of a cucumber ###" and return 76
2.2.3 If potato, print "### The life cycle a potato ###" and return 120
2.3 With the growth cycle number returned, your program should print "A seed takes <growth_number> days to reach maturity."
If not, your program should print "Your plant is available, please try "strawberry", "cucumber" or "potato"
Example
Input
potatoOutput
### The life cycle of a potato ### A seed takes 120 days to reach maturity.Input
MangoOutput
Your plant is available, please try "strawberry", "cucumber" or "potato"References
Strawberry growth cycle
Cucumber growth cycle
Potato growth cycle
This is my code below:
if __name__ == "__main__":
plant_name = input()
plant_name = plant_name.lower()
calculate_growth_cycle(plant_name)
The lab say:
Function works incorrectly, check the parametrs and return values
As given, I need to write a Python program according to the given requirements.
What's wrong with your code is -
You have not returned any value in your function calculate_growth_cycle(). The number of days should be returned in the function. As you haven't done that part, you are getting an error.
I have provided the complete code with detailed comments and output screenshots in the following steps.
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 4 images
- Cell phone packages please answer the following question in javaarrow_forwardGroup Project In Java(Airline System) A small airline has just purchased a computer for its new automated system. You have been asked to develop the new system. You are to write an application to assign seats on each flight of the airline’s planes.1. Your application should display the following alternatives: "Please type 1 for Roundtrip" "Please type 2 for One-way"2. Enter passenger’s information (name, gender, phone number,...etc)3. Enter departure and destination airports4. Enter depart and return date(if roundtrip)5. Selection for the seatIf the user types 1, your application should provide inputs for both departure and destination airports and corresponding dates. If the user types 2, your application should only provide inputs for departure airport and depart date. Your application should also display a set of inputs for passenger information.Use a one-dimensional array of primitive type boolean to represent the seating chart of the plane. Initialize all the elements of the…arrow_forwardCreate an Organization class. Organization has 10 Employees (Hint: You will need an array of pointers to Employee class) Organization can calculate the total amount to be paid to all employees Organization can print the details(name & salary) of all employees note: write code in main,header and function.cpp filearrow_forward
- class Artist{StringsArtist(const std::string& name="",int age=0):name_(name),age_(age){}std::string name()const {return name_;}void set_name(const std::string& name){name_=name;}int age()const {return age_;}void set_age(int age){age_=age;}virtual std::string perform(){return std::string("");}private:int age_;std::string name_;};class Singer : public Artist{public:Singer():Artist(){};Singer(const std::string& name,int age,int hits);int hits() const{return hits_;}void set_hits(int hit);std::string perform();int operator+(const Singer& rhs);int changeme(std::string name,int age,int hits);Singer combine(const Singer& rhs);private:int hits_=0;};int FindOldestandMostSuccess(std::vector<Singer> list); Task: Implement the function int Singer::changeme(std::string name,int age,int hits) : This function should check if the values passed by name, age and hits are different than those stored. And if this is the case it should change the values. This should be done by…arrow_forwardJAVA:arrow_forwardKindly solve this C++ program and follow all the instructions! Please let me know how should I contact you for further assistance. Thank you for your help!arrow_forward
- int stop = 6; int num =6; int count=0; for(int i = stop; i >0; i-=2) { num += i; count++; } System.out.println("num = "+ num); System.out.println("count = "+ count); } }arrow_forwarddef area(side1, side2): return side1 * side2s1 = 12s2 = 6Identify the statements that correctly call the area function. Select ALL that apply. Question options: area(s1,s2) answer = area(s1,s2) print(f'The area is {area(s1,s2)}') result = area(side1,side2)arrow_forwardCODE IN C# NOT JAVA (reject if you can't do C# please): Write an application that runs 1,000,000 games of craps and answers the following questions (explain each step): How many games are won on the first roll, second roll, …, twentieth roll and after the twentieth roll? How many games are lost on the first roll, second roll, …, twentieth roll and after the twentieth roll? What are the chances of winning at craps? [Note: You should discover that craps is one of the fairest casino games. What do you suppose this means?] What is the average length of a game of craps?arrow_forward
- class Artist{StringsArtist(const std::string& name="",int age=0):name_(name),age_(age){}std::string name()const {return name_;}void set_name(const std::string& name){name_=name;}int age()const {return age_;}void set_age(int age){age_=age;}virtual std::string perform(){return std::string("");}private:int age_;std::string name_;};class Singer : public Artist{public:Singer():Artist(){};Singer(const std::string& name,int age,int hits);int hits() const{return hits_;}void set_hits(int hit);std::string perform();int operator+(const Singer& rhs);int changeme(std::string name,int age,int hits);Singer combine(const Singer& rhs);private:int hits_=0;};int FindOldestandMostSuccess(std::vector<Singer> list); Implement the function Singer Singer::combine(const Singer& rhs):It should create a new Singer object, by calling the constructor with the following values: For name it should pass a combination of be the name of the calling object followed by a '+' and then…arrow_forwardConsider the following code: tyepdef struct { char grade; float score; } student; void f() { student a = { .grade = 'C', .score = 75.0 }; student b = { .grade = 'C', .score = 75.0 }; if (!memcmp(&a, &b, sizeof(student))) { printf("Same"); } else { printf("Different"); } } What could cause the program to print "Different"? A. memcmp examines the bytes in little endian B. memcmp returns true if contents of the memory are the same; remove the ! C. memcmp always returns a non-zero value D. The compiler may have included padding in the structs E. The compiler may have arranged the fields of the two structs differentlyarrow_forwardC++ language pleasearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education