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
Create an array named itemDescription containing the following item descriptions:
Lelu [443]

Answer:

var itemDescription = ["1975 Green Bay Packers Football (signed), Item 10582", "Tom Landry 1955 Football Card (unsigned), Item 23015", "1916 Army-Navy Game, Framed Photo (signed), Item 41807", "Protective Card Sheets, Item 10041"];

Explanation:

The following solution will work with javascript. Here we've stored different items in a variable named itemDescription.

8 0
3 years ago
What is the definition of software? Group of answer choices an instruction that causes a single specific action to be performed
zmey [24]

Answer:

The answer is started from the last fourth line i.e., a series of

Explanation:

Software seems to be the set of linked commands which inform the system or smartphone what tasks to do as well as how to execute.

In the simple words, the software is the set of the program that direct the following smartphones and also the systems that how they work and how to perform these works accurately.

So, the following are the reasons that describe the other options that are not appropriate for software.

7 0
3 years ago
Which task is not possible with VLOOKUP?
Flauer [41]

Answer:c

Explanation:

4 0
3 years ago
Read 2 more answers
What type of volcano is Dukono
ValentinkaMS [17]
Dukono is an active volcano located in the northern part of Halmahera island, Indonesia. It has a broad profile and is capped by compound craters.
8 0
2 years ago
What is the answer ????​
gtnhenbr [62]

Answer:

<h2>iv. NINGUNO DE LOS ANTERIORES</h2>

Explanation:

<h2>Hola</h2>
8 0
3 years ago
Other questions:
  • you want to discard your old computer ,want to securely erase that data from your hard drive. what can you use to do this and wh
    12·1 answer
  • How many host ip addresses are available on a network with a subnet mask of 255.255.255.192?
    6·1 answer
  • There is no way to see how another project in Scratch was made.<br><br> True<br> False
    11·1 answer
  • What is the printout (display) of the following program? public class Test { public static void main(String[] args) { int[][] va
    9·1 answer
  • Brainliest to whoever answers this first, i need help explaining.
    8·1 answer
  • If you want to insert a table which ribbon should you select
    13·2 answers
  • I made Pico with a Ray Gun (Next is Dad/Tankman)<br><br> Opinons?
    11·2 answers
  • Electronic mail is best used to:
    5·2 answers
  • Plsss help me plsssssss
    11·1 answer
  • What do you call a collection of pre-programmed commands and functions used in programs?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!