Auction project in python with source code

Auction project in python with source code

Introduction

Auction project is an auction-based command line project. It is coded in python programming. Auction project is a representation of how an auction works.

Auction project is using Python 3.8 version. An auction is a system of buying and selling assets where potential buyers place competitive bids on assets and services The buyer who bids highest price for assets can only buy. This is a system where a low price asset can be sold on higher prices. Auction project is based on this auction where bidding takes place. It executes in command line.

When you execute this project, you will see an asci art and some text. You are asked to enter your name and price first. After you enter the price, the system will ask again for another bidder. If there is another bidder who says yes, then he will bid higher price than the previous and if no the highest bidder takes the assets. This project is a beginner level project and does not works in the real world. See the screenshot below.

auction project

Check the code below.

import clear
logo = '''
                         ___________
                         \         /
                          )_______(
                          |"""""""|_.-._,.---------.,_.-._
                          |       | | |               | | ''-.
                          |       |_| |_             _| |_..-'
                          |_______| '-' `'---------'` '-'
                          )"""""""(
                         /_________\\
                       .-------------.
                      /_______________\\
'''

print(logo)
print("We have an auction for an antique bracelets. ")
print("Are there any bidders active today? Please...\n")

bids = {}
bidding_finished = False

def find_highest_bidder(bidding_record):
    highest_bid = 0
    winner = ""
    # bidding_record = {"Angela": 123, "James": 321}
    for bidder in bidding_record:
        bid_amount = bidding_record[bidder]
        if bid_amount > highest_bid:
            highest_bid = bid_amount
            winner = bidder
    print(f"The winner is {winner} with a bid of ${highest_bid}")


while not bidding_finished:
    name = input("What is your name?: ")
    price = int(input("What is your bid?: $"))
    bids[name] = price
    should_continue = input("Are there any other bidders? Type 'yes or 'no'.\n")
    if should_continue == "no":
        bidding_finished = True
        find_highest_bidder(bids)

    elif should_continue == "yes":
        find_highest_bidder(bids)
        clear

How to use this auction project?

  • Copy and paste the code in your editor. (vs code, pycharm)
  • Execute the code.
  • Use the auction project.