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]
2 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]2 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
Java Homework:(The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses nam
miss Akunina [59]

Answer: Wait, so what is the question exactly..?

8 0
3 years ago
Data is best described as
viktelen [127]

Answer:

The answer is B

Explanation:

TOOK THE TEST

5 0
3 years ago
Read 2 more answers
Which of the following tasks can you perform using a word processor?
My name is Ann [436]
Create a outline of sections to be included in a document
8 0
3 years ago
E-mail is an temporary message medium.<br> a. True<br> b. False
Volgvan

E-mail stands for Electronic mail. It is a method of exchanging messages ("mail") between people in a telecommunication network with the usage of electronic devices. There is a sender and a receiver for any given message, and they switch positions in turn.

The statement that E-mail is an temporary message medium is false. E-mail can be kept forever and are not temporary.


6 0
3 years ago
Read 2 more answers
What conversion factor should be used to convert from meters to Gigameters?
hodyreva [135]
Meters * 1,000,000,000 = gigameters
5 0
3 years ago
Other questions:
  • End-user development: the process by which an organization's non-it specialists create software applications.
    8·1 answer
  • False when you tap or click the ‘decrease font size’ button, excel assigns the next lowest font size in the font size gallery to
    13·1 answer
  • The while loop is a pre-test loop? TRUE OR FALSE
    9·2 answers
  • To prevent unauthorized access and use, at a minimum a company should have a written __________ that outlines the activities for
    6·1 answer
  • Imported data that maintains a refreshable link to its external source is called ____ data.
    7·1 answer
  • When projecting a presentation on a large screen, what should your minimum font size be?
    6·2 answers
  • An incurred cost that cannot be recovered, which is irrelevant for all decisions about the future, is included in the projected
    14·1 answer
  • Why would you use quotation marks in a search string when conducting an internet search?
    12·1 answer
  • For each of the following application areas state whether or not the tree data structure appears to be a good fit for use as a s
    8·1 answer
  • WILL GIVE BRAINLIEST! 20 POINTS! PLZ HELP!
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!