Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Ckrey auction is a kind of auction in which the bidder with the highest bid wins

ID: 3886415 • Letter: C

Question

Ckrey auction is a kind of auction in which the bidder with the highest bid wins, but the price paid is the amount of the and highest bid. We'll write a little program to implement this idea by doing the following: Have the user input a list of floating-point numbers representing the bid amounts separated by spaces. This should be entered on a single line. Use the split() method to split the input line into substrings. Convert the list of strings you created in the previous step into a list of floating-point numbers. Use the sorted() function to produce a new list of numbers in increasing (ascending) order. Print the highest and second-highest bids. You can assume that there are at least two bids, and do not worry about what to do in the event of a tic.

Explanation / Answer

#get input from user
bids = raw_input("Enter floating point numbers:")
#split by space
blist = bids.split(' ')
#convert to float
for i in range(len(blist)):
blist[i] = float(blist[i])
#sort in ascending order
blistinc = sorted(blist)
#print hightest 2 bids
print blistinc[-1],blistinc[-2]

"""
sample output

Enter floating point numbers: 1.2 3.4 4.5 1.1 6.8 3.9
6.8 4.5
"""