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.