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
Whats with the bot spamming customer care numbers...kinda annoying when im trying to help people.
Norma-Jean [14]

Answer:

yes

Explanation:

5 0
3 years ago
Draw AND, OR, XOR and XNOR gates with truth table and logic gates.<br><br>.​
timofeeve [1]

Answer:

see picture. let me know if you have questions.

7 0
2 years ago
Which statement describes one drive?
Ipatiy [6.2K]
One drive is microsofts storage service for holding files in the “cloud”. It offers users a simple way to store and sync various types of files with other people/devices on the internet.
6 0
3 years ago
Two categories of payroll deductions are required deductions and ___ deductions.
alukav5142 [94]

Answer:

1.)

- C.) Optional

2.)

- D.) Short-term Notes Payable

3.)

- A.) Payroll Sinking Funds

4.)

- A.) A Formal Timekeeping System Is Used

(I'm possibly wrong on the last question, if so then my apologies and I wish you the best of luck.)

3 0
2 years ago
Read 2 more answers
Ally made the net below to find the surface area of a box she was designing. The box measures 12 centimeters long by 9 centimete
jarptica [38.1K]

The area of the box is 972.

7 0
3 years ago
Other questions:
  • Write a program that reads in the length and the width of a rectangular yard.
    5·1 answer
  • Hybrid protocol is similar to which other protocol?
    10·1 answer
  • Which technique helps you look confident as a speaker?
    15·1 answer
  • Presses the Schedulr app icon Selects the list item for CSCI 448 Presses the "View Classroom on Map" button While only performin
    11·1 answer
  • If you want to present slides to fellow students or coworkers which productivity software should you use to create them A. Word
    14·2 answers
  • What do you call the destination router on the network endpoint?
    7·1 answer
  • The name of a person their address and their contact information like phone number and email address or consider the minimum inf
    9·1 answer
  • 3.<br>Give two reasons why everyone should study technology<br>​
    10·1 answer
  • Which of the following is the file type of Microsoft® Publisher files?
    12·2 answers
  • Which privacy protection uses four colors to indicate the expected sharing limitations that are to be applied by recipients of t
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!