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
design a relational database in EER for bike helmets and their reviews. a bike helmet has a name and color attributes. a bike co
Law Incorporation [45]

Answer:something you gotta do on your own

Explanation:

7 0
3 years ago
Which of the following BEST describes the relationship between the Boston Marathon bombing and biometrics?
ale4655 [162]

Answer:

Because of the newly developed biometric technology, the FBI was able to

quickly identify two suspects.

The blurry photos released by the FBI after the bombing prompted

researchers to improve their early biometric software.

Because biometric technology was unavailable at the time, the Boston

Marathon bomber remains at large.

The Boston Marathon bombing made researchers aware of how biometric

technology is sometimes useless and ineffective.

Explanation:

6 0
2 years ago
Hello users !
vazorg [7]

no here r the ranks:Beginner

Helping Hand

Virtuoso

Expert

and genius

5 0
3 years ago
Read 2 more answers
You are trying to access WiFi network at a coffee shop. What protocol will this type of wireless networking most likely use?
monitta
The answer to your question is a password
3 0
3 years ago
This project involves writing a java program to simulate a blackjack card game. You will use a simple console-based user interfa
coldgirl [10]

Answer:i dont know sorry

Explanation:

8 0
3 years ago
Other questions:
  • What's another name for the Super High shot, if you shot it on the ground using a tripod?
    14·1 answer
  • WILL GIVE BRAINLIEST! A rent payment is an example of which type of expense?
    14·2 answers
  • What category of sensory receptors are sensitive to touch sound and motion?
    10·1 answer
  • PLEASE HELP ASAP!!!
    8·1 answer
  • Which of the following are examples of how a company might use consumer data it had collected? a To decide what types of product
    10·1 answer
  • If you need seamless access to the OS, ________ is better.
    8·1 answer
  • Can anyone please help me to solve this question?
    10·1 answer
  • A local bank has just one branch. It sets up a peer-to-peer network for all devices on the system. The bank would like to be abl
    8·2 answers
  • NEED ANS ASAP THANK YOU
    14·1 answer
  • How do I make my header line visible?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!