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
As part of his proofreading process, and to catch any spelling or grammar mistakes, John uses this feature in Word Online to hav
UkoKoshka [18]
Microsoft word online uses “Proofing Tools”, it can check spelling and grammar, translate the document, and set the proofing language. Word for the web does not use a custom dictionary or include a thesaurus.
5 0
3 years ago
Applications of the e-government​
vodka [1.7K]

Answer:

Elections

Explanation:

This is because the applications helps citizens to carry out legal elections without stress of moving long distances and it helps keeps votes secret coz of personal view of the data entry

5 0
2 years ago
Read 2 more answers
A _____ is a machine that changes information from one form into another.
gavmur [86]
The answer would be computer
5 0
2 years ago
When there are items that are out of the control of the programmer that may support or oppose the program goals, this is termed
netineya [11]

Answer:

Option D (External influences) is the correct choice.

Explanation:

  • External factors including certain regulatory changes, the economy, globalization as well as new technologies may determine the effectiveness of such smaller businesses.
  • They are the be the variables that may be out of a corporation's influence. While a company has no power regarding external factors, these factors may have a direct effect on the company.

Other given choices are not related to the given circumstances. So that option D would be the right one.

3 0
3 years ago
Your program has a loop. You want to exit the loop completely if the user guesses the correct word.
Wewaii [24]

Answer:

Continue

Explanation:

8 0
2 years ago
Read 2 more answers
Other questions:
  • Create a class named Person that holds the following fields: two String objects for the person’s first and last name and a Local
    5·2 answers
  • A machine is classified as a compound machine if it?
    8·2 answers
  • for what reason do some security professionals consider insiders more dangerous than outside intruders?
    8·1 answer
  • A _______________ is a security threat that may launch a worm through a Trojan horse or launch a denial-of-service attack at a t
    10·1 answer
  • Jenny is working on a laptop computer and notices that the computer is not running very fast. She looks and realizes that the la
    14·1 answer
  • What will be the results from running the following code?
    5·1 answer
  • Which memory can be removed from motherboard? RAM OR ROM?​
    11·1 answer
  • 1- pensamiento sistémico<br>2- visión oriental y occidental​
    8·1 answer
  • Anyone have any website ideas I could use for my computing website project? Thank you.
    15·2 answers
  • What does playstation network is currently undergoing maintenance?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!