Question

**** CREATE A PROGRAM USING PYTHON **** You have two apple trees in your backyard. You...

**** CREATE A PROGRAM USING PYTHON ****

You have two apple trees in your backyard. You want to create a program that will display a graph of how many apples your trees have lost in one day. Trees lose apples based on two factors: has the tree turned color yet and is it windy. If it is windy and the tree has turned color then your tree will lose 10 apples every 6 hours. If it is windy and your tree has not turned color, your tree will lose 3 apples every 6 hours. If it is not windy and your tree has turned color, your tree will loose 5 apples every 6 hours. Finally if it is not windy and your tree has not turned color, your tree will lose 1 apple per 6 hours.
Your program, therefore, needs to ask the user if it is windy and if your two trees have turned color. The output for the program will be the display of a graph.

Your output should look similar to this:

Is it windy today (yes or no): no
Has your first tree turned color yet (yes or no): no
Has your second tree turned color yet (yes or no): yes
Tree 1 | Tree 2
========================
   *** | ***
   *** | ***
   *** | ***
   *** | ***
   *** | ***
       | ***
       | ***
       | ***
       | ***
       | ***
       | ***
       | ***
       | ***
       | ***
       | ***
       | ***
       | ***
       | ***
       | ***
       | ***
       | ***
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#taking input from user
wind = input("Is it windy today(yes/no): ")
tree1 = input("Has your first tree trurned color yet(yes/no): ")
tree2 = input("Has your second tree trurned color yet(yes/no): ")

#finding the number of fruits dropped per 6hrs
#according to the given conditions
def fruitsDropped(wind, tree):
fruitsDrop = 0
if (wind == "yes" and tree == "yes"):
fruitsDrop = 10
elif (wind == "yes" and tree == "no"):   
fruitsDrop = 3
elif (wind == "no" and tree == "yes"):   
fruitsDrop = 5
elif (wind == "no" and tree == "no"):   
fruitsDrop = 1
else:
None
return fruitsDrop
  
#printing the graph for 24 hrs
print("Tree 1 | Tree 2\n========================")
for i in range(4):
print("%s|%s"%("*"*fruitsDropped(wind,tree1),"*"*fruitsDropped(wind,tree2)))

Output:

Is it windy today(yes/no):  yes
Has your first tree trurned color yet(yes/no):  yes
Has your second tree trurned color yet(yes/no):  yes
Tree 1 | Tree 2
========================
**********|**********
**********|**********
**********|**********
**********|**********

Anand O replit - C Compiler xreplit - Python3 Compilex KCSecure https://repl.it/N3xF ganandababu_rgufuntitled my repls commun

Add a comment
Know the answer?
Add Answer to:
**** CREATE A PROGRAM USING PYTHON **** You have two apple trees in your backyard. You...
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
  • Using python, create a program using nested loops to write a function called substring(s,b) that returns...

    Using python, create a program using nested loops to write a function called substring(s,b) that returns True or False depending on whether or not b is a substring of s. For example: String: "Diamond" Substring: "mond" The code will then state that this is true and "mond" is a substring of "Diamond". Example of what the program should output: Enter string: Tree Enter substring: Tre Yes, 'Tre' is a substring of 'Tree' Limitation: This program cannot use "find()" and "in"...

  • Binary trees - C programming; Write a program in C, you must have as input a...

    Binary trees - C programming; Write a program in C, you must have as input a .txt file (start.txt) which represents a binary tree, Edges as pairs (x, y), x and y refer to the names of the nodes , and have as output answering questions about the tree.EX Input (start.txt): (1,2) (1,3) (2,4) (2,5) (3,6) (3,7) (4,8) Output(output.txt): Is the tree complete? YES What is the weight of the tree? 4 Is it balanced? YES

  • Binary trees - C programming; Write a program in C, you must have as input a...

    Binary trees - C programming; Write a program in C, you must have as input a .txt file (start.txt), and have as output answering questions about the tree. Edges as pairs (x, y), x and y refer to the names of the nodes Input (start.txt): (1,2) (1,3) (2,4) (2,5) (3,6) (3,7) (4,8) Output(output.txt): Is the tree complete? NO What is the weight of the tree? 4 Is it balanced? YES

  • Using Python. You will create two classes and then use the provided test program to make sure your program works This m...

    Using Python. You will create two classes and then use the provided test program to make sure your program works This means that your class and methods must match the names used in the test program You should break your class implementation into multiple files. You should have a car.py that defines the car class and a list.py that defines a link class and the linked list class. When all is working, you should zip up your complete project and...

  • Create a Python program using a list. You are the owner of a cheese shop, "The...

    Create a Python program using a list. You are the owner of a cheese shop, "The Deceased Macaw" and a customer has arrived. Write a program to greet them. You should first ask if the customer is interested in cheddar, if so, then they are given cheddar. Otherwise, you say that you'll find something. If they say that they don't want cheese, you ask them why they are in a cheese shop? In this exercise, valid user responses are "yes"...

  • PYTHON 3 CODING Review the following tree and then implement Depth First Traversals. Your program should...

    PYTHON 3 CODING Review the following tree and then implement Depth First Traversals. Your program should display the output from Inorder to Preorder and Postorder. Include the following items in your answer: Write the implementation for Inorder, Preorder, and Postorder Print the output for each of the Inorder, Preorder, and Postorder Use the following steps to help with your solution: Create the node structure. Each node structure should contain the data, left node and right node. Create a function to...

  • Provide Python code that does the following: Create the following list in your program: lst1 =...

    Provide Python code that does the following: Create the following list in your program: lst1 = ["apple", "banana", "pear", "grapefruit", "pineapple", "grape", "guava", "plum", "peach"] Write code that then does the following: Print the last item in the list. Print the first item in the list. Print all but the last three items in the list. Print the first, third, fifth etc. items of the list. Print the second, fourth, sixth etc. items of the list. Parts A- E should...

  • Write a python program where you create a list (you an create it in code you...

    Write a python program where you create a list (you an create it in code you do not have to use input() statements) that represents the total rainfall for each of 12 months (assume that element 0 is January and element 11 is December). The program should calculate and display the: 1) total rainfall for the year; 2) the average monthly rainfall; 3) the months with the highest and lowest amounts. You need to figure out how to access each...

  • The goal is to create a code for implementing a Columns game using pygame Your program...

    The goal is to create a code for implementing a Columns game using pygame Your program will read its input via the Python shell (i.e., using the built-in input() function), printing no prompts to a user with no extraneous output other than precisely what is specified below. The intent here is not to write a user-friendly user interface; what you're actually doing is building a tool for testing your game mechanics, which we'll then be using to automatically test them....

  • [Using Python] Create a program to generate one random question, from a list of 5, for...

    [Using Python] Create a program to generate one random question, from a list of 5, for each repeated run. Report the number of the correct answers after all five questions have been answered. Your 5 questions should be a simple math problem, like "what is 5-4?" use a while loop based on the number of questions use a counter variable to count the number of questions asked e.g. questionCount +=1 user a counter variable to keep track of the correct...

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