Question

python 3 A grocery store keeps track of the fruits it has sold. Currently it only...

python 3

A grocery store keeps track of the fruits it has sold. Currently it only tracks apples and bananas. Write a program that first asks the user to enter how many days he/she wants to record, then for each day prompts the user to enter the profit of selling apples and bananas respectively. The program should display the total profit made by selling the two fruits over all these days, and show which fruit -- apples or bananas -- makes more profit.

Sample input & output: (Prompt) Enter the number of days: (User enter) 2 (Prompt) Enter the profit for apples on Day 1: (User enter) 40 (Prompt) Enter the profit for bananas on Day 1: (User enter) 80 (Prompt) Enter the profit for apples on Day 2: (User enter) 60 (Prompt) Enter the profit for bananas on Day 2: (User enter) 40 (Output) The total profit (including both apples and bananas) is $ 220.0 (Output) Selling bananas makes more profit.

Homework Answers

Answer #1
 
#take number of days from user
numberOfDays=int(input("Enter the number of days:"))

#assign totalprofit from banana and apple as zero
profitFromBananas=0
profitFromApples=0

#input daily profit from user for all days
for day in range(0,numberOfDays):
    print("Enter the profit for apples on Day ",day+1)
    dailyProfitApples=int(input())
    print("Enter the profit for bananas on Day ",day+1)
    dailyProfitBanana=int(input())
    # adding to total profit
    profitFromBananas=profitFromBananas+dailyProfitBanana
    profitFromApples=profitFromApples+dailyProfitApples

# print total profit
totalProfit=profitFromApples+profitFromBananas
print("total profit (including both apples and bananas) is $", totalProfit)
#print which fruit makes more profit
if profitFromBananas>profitFromApples:
    print("Selling bananas makes more profit.")
elif profitFromBananas<profitFromApples:
    print("Selling apples makes more profit.")
else:
    print("Selling apples and bananas makes equal profit.")
Know the answer?
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
Similar Questions
Please use Python 3 4). Write a program that asks the user to enter 10 numbers....
Please use Python 3 4). Write a program that asks the user to enter 10 numbers. The program should store the numbers in a list and then display the following data: • The lowest number in the list • The highest number in the list •The total of the numbers in the list • The average of the numbers in the list   Sample input & output: (Prompt) Enter Number 1: (User enter) 4 (Prompt) Enter Number 2: (User enter) 7...
NOTE:- PLEASE USE THE INSTRUCTION ACCORDING TO "CHAPTER 3" OF "STARTING OUT WITH PYTHON 4TH EDITION"...
NOTE:- PLEASE USE THE INSTRUCTION ACCORDING TO "CHAPTER 3" OF "STARTING OUT WITH PYTHON 4TH EDITION" PROGRAM 3_1:- Write a program that determines the cost of online order of T-shirts. T-shirts are priced at $12.99 each, but discounts are applied for quantities as follows: - 12 or more shirts earn a 30% discount and free shipping - 6-11 shirts earn a 20% discount - and 3-5 shirts earn a 10% discount - 1 or 2 shirts, no discounts Prompt the...
How much money do you think you would earn in a period of 30 days if...
How much money do you think you would earn in a period of 30 days if you were paid as follows: one cent for the first day, two cents for the second day, four cents for the third day, eight cents for the fourth day, and so on (i.e. your salary doubles each day)? Do you think you would make very little money, just a few dollars, at the end of the 30-day period? Let us write a program to...
We constantly seem to be pricing ourselves out of some markets and not charging enough in...
We constantly seem to be pricing ourselves out of some markets and not charging enough in others. Our pricing policy is pretty simple: we mark up our full manufacturing cost by 50%. That means a computer that costs us $2,000 to manufacture will sell for $3,000. Until now I thought this was a workable approach, but now I’m not so sure. Steve Works, CEO, Cortland Manufacturing, Inc. (CMI) Steve’s Controller, Sally Nomer, had just told him that she believed the...
Wal-Mart Online Wal-Mart is one of the largest companies in America. It is definitely the largest...
Wal-Mart Online Wal-Mart is one of the largest companies in America. It is definitely the largest retailer, both in terms of the number of stores (8,970 worldwide in 2011) and the level of sales ($419 billion from the 2011 Annual Report). By pushing suppliers to continually reduce costs, Wal-Mart is known for pursuing low prices and the stores often attract customers solely in-terested in lower prices. With Wal-Mart’s expansion into groceries, the company has be-come the largest retail grocer in...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT