DEV Community

Cover image for Day 08 of My AI & Data Mastery Journey: From Python to Generative AI
Nitin-bhatt46
Nitin-bhatt46

Posted on

Day 08 of My AI & Data Mastery Journey: From Python to Generative AI

*Project 1 :- *

Bidding System

  1. Set bidding as active
  2. Create an empty data dictionary with two keys: ‘name’ and ‘bid’, each containing an empty list
  3. Repeat while bidding is active: • Ask the user to enter their name • Ask the user to enter their bid amount (as an integer) • Append the name to the ‘name’ list in the dictionary • Append the bid to the ‘bid’ list in the dictionary • Display all items in the data dictionary so far • Ask the user if another bid should be entered (y/n) • If the answer is 'n', end the bidding loop
  4. After all bids are collected: • Find the highest bid value in the ‘bid’ list • Get the index of this highest bid in the ‘bid’ list • Find the name at this index in the ‘name’ list
  5. Display the winner’s name and their bid amount

👉 "For hands-on practice, the code used in this lesson is available in my GitHub repository. Please refer to the GitHub link provided in the bio."

*HANDS_ON :- *

Now it’s time for some hands-on practice.
Creation Question (Day 8 — “Smart Auction Tracker”)
You are helping a small online auction startup that sells limited-edition sneakers.

Buyers can place multiple bids on different sneaker models.
At the end of the day, the company wants to know which sneaker got the highest bid and who placed that bid.
However:
• If two people bid the same amount on a sneaker, the earliest bidder wins.
• You must handle multiple sneakers being auctioned simultaneously.
• You should show the winning bidder for each sneaker.


🧩 Your Task
Write a program that:

  1. Asks the user to enter: o Sneaker name (e.g., “Air Jordan 1”) o Bidder name o Bid amount (integer)
  2. Stores the data for multiple bids in a structured format (you may use lists or nested lists — avoid using dictionaries for now).
  3. After all bids are entered, display: o The winner’s name and bid amount for each sneaker.
  4. Implement tie-breaking logic (if two bids are equal, earliest wins)

👉 "For hands-on practice, the code used in this lesson is available in my GitHub repository. Please refer to the GitHub link provided in the bio."

*DEBUGGING :- *

Debug Question :-

Context: This is a very small piece of code intended to pick the winner from a bids list. It contains two realistic bugs: (A) it uses Python max() incorrectly on tuples and (B) it mishandles ties (recent bid wins instead of earliest). Your job: find the bugs, fix them, and explain what you changed.
Buggy snippet (copy exactly, small)

bids is a list of tuples: (name, amount, time)

bids = [('alice', 120, 1), ('bob', 150, 2), ('carol', 150, 3), ('dave', 90, 4)]

intended: find highest bid and earliest if tie

top = max(bids) # BUG-1: incorrect usage
winner_name = top[0]
winner_amount = top[1]

print(f"Winner is {winner_name} with {winner_amount}")

Your task (what to change)

  1. Replace max(bids) with logic that selects the tuple with highest amount and in case of equal amount picks the smallest time (earliest).
  2. Keep the solution minimal — a short loop or max() with a proper key lambda that handles tie by time correctly.

👉 "For hands-on practice, the code used in this lesson is available in my GitHub repository. Please refer to the GitHub link provided in the bio."

Top comments (0)