Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Important: program should allow user to put input SAMPLE inputs from attached file are ONLY for reference on how the program should run. i dont want to program only to run on the sample inputs. it...

1 answer below »

Important: program should allow user to put input
SAMPLE inputs from attached file are ONLY for reference on how the program should run. i dont want to program only to run on the sample inputs. it should work with any inputs the user enters

Alfons wants to set up a hot dog stand. He has done some research to find out how many Czech crowns (Kč) people are willing to pay for a hot dog. This has yielded a large set of integers, each of which indicates the maximum price that a certain person will pay.

Alfons wants to set his price to maximize his revenue. If the price is too low, almost everyone will buy a hot dog, but the income from each hot dog he sells will be small. If the price is too high, few people will buy a hot dog and so Alfons's total revenue will also be small.

The program's input consists of integers in the range from 1 to 1000 onone or more lines, separated by whitespace. Each of these indicates the maximum price that one customer has said he/she will pay for a hot dog. The numbers in the input are not sorted in any way, and values may appear more than once.

The program should write a single integer to standard output: the selling price of a single hot dog such that Alfons's revenue will be as large as possible. If there is more than one price that will achieve the maximum revenue, the program should write thelowestof these.


Answered Same Day Oct 28, 2021

Solution

Yogesh answered on Oct 30 2021
154 Votes
def find_price(prices):
    # {price : revenue} dictionary
    price_dict = {}
    
    # take each price from the inputs prices
    for p in prices:
        # customer counter for each price
        count = 0
        for q in prices:
            if q >= p:
                count += 1
        # Add element into dictionary as {price : revenue}
        price_dict[p] = count * p
        
    #print(price_dict)
    # get the maximum revenue...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here