bidding algorithm python

Solutions on MaxInterview for bidding algorithm python by the best coders in the world

showing results for - "bidding algorithm python"
Francesca
20 Jun 2020
1import os
2
3bids = {}
4bidding_finished = False
5
6def find_highest_bidder(bidding_record):
7  highest_bid = 0
8  winner = ""
9  # bidding_record = {"Angela": 123, "James": 321}
10  for bidder in bidding_record:
11    bid_amount = bidding_record[bidder]
12    if bid_amount > highest_bid: 
13      highest_bid = bid_amount
14      winner = bidder
15  print(f"The winner is {winner} with a bid of ${highest_bid}")
16
17while not bidding_finished:
18  name = input("What is your name?: ")
19  price = int(input("What is your bid?: $"))
20  bids[name] = price
21  should_continue = input("Are there any other bidders? Type 'yes or 'no'.\n")
22  if should_continue == "no":
23    bidding_finished = True
24    find_highest_bidder(bids)
25  elif should_continue == "yes":
26    os.system("cls")