Question: write a python code!! i need a python code sample output: The Market Garden Simulator is a program that simulates the tranquil and refreshing activity















The Market Garden Simulator is a program that simulates the tranquil and refreshing activity of growing your own garden for fun and profit. You have a list of plants, which each generate "food" according to their name length (as everyone knows, longer plant names mean higher profit at market... but they cost more to buy). Each day when you wait and watch, it rains a random amount. This rainfall determines how much food the plants generate, but if you don't get enough rain, a random plant will die. When you have enough food, you can spend some to buy new plants. To increase the biodiversity of your garden, you can't buy plants you already have. The program starts with a welcome, some instructions and four plants. Then there's a repeating menu with the following four options (read the sample output to understand in more detail): (W)ait o This simulates a day starting with rainfall between 0 and 100mm (think about constants). If you get less than 30mm (did someone say think about constants?) then a random plant from your list will die (and be deleted from the list). Each plant generates an amount of food according to the formula: (random value between 1/2 rainfall and actual rainfall) / 100 * length e.g., if rainfall is 70, then a random value between 0.35 and 0.7 would multiply the length of each plant, so "Sage" plant (4 characters) would produce a result between (0.35 and 0.7 * 4) 1.4 and 2.8 as an integer so 1 to 2, and "Thai Basil" (10 characters) would produce between 3 and 7. . (Display plants o This simply displays the plants in your garden. (A)dd new plant o You can only add plants you can afford. You can have an infinite number of plants. New plant names cannot be blank; error-check and repeat for blank names. Plant names should be converted to title case (using Python's.title() string method), so if the user enters thai BASIL", it will become "Thai Basil". If you already have the plant in your list, then you will be asked for the name again. When you add a plant, the name length is deducted from your food. (Q)uit o This will end the main menu and show the final details including the plants, the number of days simulated, the number of plants and the amount of food. Notice that you have been taught how to write menus and you know that (Q) should not be a separate option within the menu, but rather the quit loop condition with final actions coded outside the main menu loop. Make sure you understand how the program should work (that's the "analysis" step in program development) before you plan it ("design" step), then code it ("implementation"). Don't forget to test your program thoroughly, comparing it to these requirements. Coding Requirements and Suggestions: Make use of named constants as appropriate, e.g., for things that would otherwise be "magic numbers", like the maximum rainfall or low rainfall threshold for plant death. Remember the guidelines for constants: if you use a value more than once, it should probably be a constant, and if you have a constant then you must use it in all places that you reference that value. A very good way to test that you have used constants properly is that you should be able to change ONE value in ONE place to make the low rain threshold 20 mm... and the instructions should correctly show this. That's what constants are for. You are expected to include two kinds of useful comments in each of your program: o Every function should have a "docstring". See the subject teaching for how to properly write docstrings. o Use #block comments for things that might reasonably need a comment Do not include unnecessary or many comments as these are just "noise" and make your program harder to read. . Functions should be used for sections of the program and repeated tasks as you have been taught. Follow the DRY (Don't Repeat Yourself) principle and consider turning repeated code into functions. Here are some possibilities for functions: o displaying the plants is done the same way in multiple places o adding a plant is a significant section o getting a plant name looks very similar to the kind of thing we wrote functions for in the teaching (getting a valid string) o simulating a day is a nice-sized section for its own function o the main menu and one-off program behaviour (like the start and end) should all be part of the main function. Sample output from the program is provided. You should ensure that your program mostly matches this and definitely does in terms of meeting the requirements. Sample output: It should be clear which parts below are user input (not printed, but entered by the user). Notice that the menu handles uppercase and lowercase letters. Welcome to the Market Garden Simulator Plants cost and generate food according to their name length (c.g., Sage plants cost 4). You can buy new plants with the food your garden generates. You get up to 100 mm of rain per day. Not all plants can survive with less than 30. Let's hope it rains... a lot! You start with these plants: Parsley, Sage, Rosemary, Thyme, After 0 days, you have 4 plants and your total food is 0. (W)ait (Display plants (A)dd new plant (Q)uit Choose: u Invalid choice After 0 days, you have 4 plants and your total food is 0. (W)ait (Display plants (A)dd new plant (Quit Choose: D Parsley, Sage, Rosemary, Thyme, After 0 days, you have 4 plants and your total food is 0. (W)ait (D)isplay plants (A)dd new plant (Q)uit Choose: a Enter plant name: Fern Fem would cost 4 food. With only 0, you can't afford it. After 0 days, you have 4 plants and your total food is 0. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: w Rainfall: 90mm Parsley produced 3, Sage produced 1, Rosemary produced 3, Thyme produced 2, After 1 days, you have 4 plants and your total food is 9. (W)ait (Display plants (A)dd new plant (Q)uit Choose: W Rainfall: 74mm Parsley produced 3, Sage produced 1, Rosemary produced 3, Thyme produced 2, After 2 days, you have 4 plants and your total food is 18. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: w Rainfall: 38mm Parsley produced 2. Sage produced 1, Rosemary produced 2, Thyme produced 1, After 3 days, you have 4 plants and your total food is 24. (W)ait (Display plants (A)dd new plant (Quit Choose: a Enter plant name: Invalid plant name Enter plant name: Sage You already have a Sage plant. Enter plant name: SWEET potato After 3 days, you have 5 plants and your total food is 12. (W)ait (Display plants (A)dd new plant (Quit Choose: w Rainfall: 8mm Sadly, your Sweet Potato plant has died. Parsley produced 0, Sage produced 0, Rosemary produced 0, Thyme produced 0, After 4 days, you have 4 plants and your total food is 12. (W)ait (Display plants (A)dd new plant (Quit Choose: a Enter plant name: SWEET potato After 4 days, you have 5 plants and your total food is 0. (W)ait (Display plants (A)dd new plant (Quit Choose: w Rainfall: 58mm Parsley produced 4, Sage produced 2, Rosemary produced 4, Thyme produced 2, Sweet Potato produced 6, After 5 days, you have 5 plants and your total food is 18. (W)ait (D)isplay plants (A)dd new plant (Q)uit Choose: w Rainfall: 3mm Sadly, your Rosemary plant has died. Parsley produced 0, Sage produced 0, Thyme produced 0, Sweet Potato produced 0, After 6 days, you have 4 plants and your total food is 18. (W)ait (D)isplay plants (A)dd new plant (Q)uit Choose: a Enter plant name: I wonder if I could have a kauri tree I Wonder If I Could Have A Kari Tree would cost 36 food. With only 18, you can't afford it. After 6 days, you have 4 plants and your total food is 18. (W)ait (D)isplay plants (A)dd new plant (Q)uit Choose: a Enter plant name: Kauri Tree? After 6 days, you have 5 plants and your total food is 7. (W)ait (Display plants (A)dd new plant (Q)uit Choose: d Parsley, Sage, Thyme, Sweet Potato, Kauri Tree?, After 6 days, you have 5 plants and your total food is 7. (W)ait (Display plants (A)dd new plant (Q)uit Choose: w Rainfall: 18mm Sadly, your Sweet Potato plant has died. Parsley produced 0, Sage produced 0, Thyme produced 0, Kauri Tree? produced I, After 7 days, you have 4 plants and your total food is 8. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: W Rainfall: 83mm Parsley produced 4, Sage produced 2, Thyme produced 3, Kauri Tree? produced 6, After 8 days, you have 4 plants and your total food is 23. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: d Parsley, Sage, Thyme, Kauri Tree? After 8 days, you have 4 plants and your total food is 23. (W)ait (Display plants (A)dd new plant (Quit Choose: 9 You finished with these plants: Parsley, Sage, Thyme, Kauri Tree?, After 8 days, you have 4 plants and your total food is 23. Thank you for simulating. Now go and enjoy a real garden. Here is the output from a second run. Notice the different ("no plants") output at the end: Welcome to the Market Garden Simulator Plants cost and generate food according to their name length (e.g., Sage plants cost 4). You can buy new plants with the food your garden generates. You get up to 100 mm of rain per day. Not all plants can survive with less than 30. Let's hope it rains... a lot! You start with these plants: Parsley, After 0 days, you have 1 plants and your total food is 0. (W)ait (Display plants (A)dd new plant (Q)uit Choose: w Rainfall: 67mm Parsley produced 2, After 1 days, you have I plants and your total food is 2. (W)ait (D)isplay plants (A)dd new plant (Q)uit Choose: w Rainfall: 15mm Sadly, your Parsley plant has died. After 2 days, you have 0 plants and your total food is 2. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: w Rainfall: 22mm After 3 days, you have 0 plants and your total food is 2. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: w Rainfall: 42mm After 4 days, you have 0 plants and your total food is 2 (W)ait (Display plants (Quit Choose: w Rainfall: 76mm Id produced 1, After 5 days, you have 1 plants and your total food is 1. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: w Rainfall: 4mm Sadly, your Id plant has died. After 6 days, you have 0 plants and your total food is 1. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: a Enter plant name: After 6 days, you have 1 plants and your total food is 0. (W)ait (D)isplay plants (A)dd new plant (Q)uit Choose: w Rainfall: 45mm produced 0 After 7 days, you have 1 plants and your total food is 0. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: w Rainfall: 15mm Sadly, your plant has died. After 8 days, you have 0 plants and your total food is 0. (W)ait (Display plants (A)dd new plant (Quit Choose: w Rainfall: 32mm After 9 days, you have 0 plants and your total food is 0. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: w Rainfall: 3mm After 10 days, you have 0 plants and your total food is 0. (W)ait (D)isplay plants (A)dd new plant Quit Choose: d After 10 days, you have 0 plants and your total food is 0. (W)ait (Display plants (A)dd new plant (Quit Choose: a Enter plant name: Nothing Nothing would cost 8 food. With only 0, you can't afford it After 10 days, you have 0 plants and your total food is 0. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: a Enter plant name: I would cost 1 food. With only 0, you can't afford it, After 10 days, you have 0 plants and your total food is 0. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: w Rainfall: 72mm After 11 days, you have 0 plants and your total food is 0. (W)ait (D)isplay plants (A)dd new plant (Quit Choose: 4 You finished with no plants After 11 days, you have 0 plants and your total food is 0. Thank you for simulating. Now go and enjoy a real garden. 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
