1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ANTONII [103]
3 years ago
5

On the classic gameshow The Price Is Right, contestants must guess the price of an object (guesses are distinct). The winner is

determined to be the person whose bid is closest to the correct price, but without going over. For example, if the guesses were Alice 430 Bob 538 Carol 487 David 550 and the true price were 520, then Carol has the winning bid with 487. With the same bids as above, if the actual price had been 420, then no one would win, as everyone bid too high. Your job is to implement a function with signature judge (auction, price) in which auction is a nonempty list of (person, guess) tuples and price is the actual price. The function must return the name of the winning person (or None, if no one wins). For example, the first scenario above might be expressed as judge( [('Alice', 430), ('Bob', 538), ('Carol', 487), ('David', 550)], 520) and the string 'Carol' should be returned as the winner. Your function may assume that all parameters are valid. []

Computers and Technology
1 answer:
Kruka [31]3 years ago
3 0

Answer:

The program code is in explaination

Explanation:

Program code below.

def judge(auction,price):

"""

Function: Returns Name who auctioned very near to give price

Input :

auction : list of tuples

price : auction price

output: returns name of best auction amount holder

"""

diff = [] #storing differences between auctionist amount and price

count = 0

for each_pair in auction:

if each_pair[1]<=price:

diff.append(price-each_pair[1])

else:

count+=1

diff.append(each_pair[1])

if count == len(auction): #check for if no one have auctioned good amount

return None

else:

more_possibility_index = diff.index(min(diff)) #finding index of best amount from diff list

return auction[more_possibility_index][0]

auction = [('Alice',430),('Bob',538),('Carol',487),('David',550)]

price = 520

print(judge(auction,price))

I kept the output at the attachment.

You might be interested in
can someone please help me with my school work you can look under my questions please help me ​my mom is going to kill me when s
Snezhnost [94]

Answer:

hey panda I'm doing good how about you

5 0
3 years ago
What are the first two models, e.g. diagrams that affect the entire system, that are built during the CoreProcess to discover an
mrs_skeptik [129]

Answer:

The answer is "Option c and Option d".

Explanation:

A diagram for a case use is a UML dynamic or computational diagram, that is used in the case diagram model. It consists of a set of actions, services, and functions to be carried out by the system. and The class diagram refers to relationships between the UML classes and the source code that dependence, that is two diagrams that affect the system and others are wrong, which can be explained as follows:

  • In option a, It is used for business process, that's is not correct.
  • In option b, It is used for both professionals industry like software and business, that's why it is wrong.
  • In option e, It is used in only high-level language, that's why it is wrong.
  • In option f, It is used to adjust its layout that's why it is wrong.

3 0
4 years ago
Hot five was the famous band of which musician?
slega [8]
Hot Five was Louis Armstrong's first recording jazz band.
4 0
4 years ago
Similarities between drawing toolbar and editing toolbar​
topjm [15]

Answer:

dk

Explanation:

3 0
3 years ago
Read 2 more answers
Question 3
goldfiish [28.3K]

Answer: Zero is output.

8 0
3 years ago
Other questions:
  • In a _____, if any link between nodes is severed, the entire network is affected, and failure of a single node disrupts the enti
    9·1 answer
  • Question / UJU
    11·1 answer
  • Design and implement a java program (name it CheckPoint) that prompts the user to enter the x-coordinate and y-coordinate of a p
    6·1 answer
  • Conduct online research on web authentication and define what it is. Describe different authentication methods
    5·1 answer
  • Assume that a text box named PhoneNumberTextBox appears on a form and contains the phone number 414-555-5555. What value will di
    5·1 answer
  • OCR Land is a theme park aimed at children and adults. Entrance tickets are sold online. An adult ticket to OCR Land costs £19.9
    7·1 answer
  • Dell Computers is a nationally recognized manufacturer of computers for the small business and home markets. If Dell were to ord
    9·1 answer
  • What do u mean by software​
    7·1 answer
  • __________ makes the hardware usable, while __________ commands it to perform specific tasks. a.) The operating system, RAM b.)
    10·2 answers
  • একটি ডকুমেন্ট তৈরী করে ড্রাইভে সেভ করার পদ্ধতি বর্ণনা করো
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!