All right. So now that you've learned all about dictionaries,
we're going to put all of that knowledge to test and to use by building a blind
auction program. So here's the program. When you first run it,
it's just going to show you the logo art and maybe a line that tells you what
program you're in. And then it's going to ask you for your name.
So let's say we have three bidders, right? So first go,
I go to the computer. I type in my name, I type in my bid and I hit enter.
It asked me if there are any other bidders, I look around the room,
I see two other colleagues. So I type yes.
And now it clears the entire screen.
So the other people can't see what my bid was.
So now I leave the computer and my colleague comes over.
They type in their name and also their bid.
And again,
they look around the room and they see this one other person who wants to bid.
So they hit yes, again, it clears their bid. And finally,
the last person makes their bid. At this point, everybody has bid
so she's going to type no.
And it's at this moment when our program is going to work out
who has made the highest bid and print out who the winner is and what their bid
was. This way, instead of competing with each other on bids,
we actually all just give the highest price we're willing to pay
and this is known as quite an efficient way of making a bid.
And you see that a lot in say the construction industry and government,
et cetera.
The important thing in this program is you're going to start out using the blind
auction start replit.
And the first thing you'll notice is that I've already imported this function
called clear from the replit module.
And you can basically call this function, clear, whenever you want to clear the
output just as you saw here. Whenever we typed yes after being asked
if there are any other bidders,
that just calls the clear
and then it gets rid of everything that's in the console. In addition,
we've also got the starting art of the gavel logo
which you're going to put into the program.
And the most important thing of all is that I want you to create a dictionary so
that each person's name will be the key and their bid will be the value.
And this dictionary is going to contain many of these key-value pairs
and at the very end of the program when everybody's done with bidding,
then we're going to loop through that dictionary and figure out who has made the
highest bid. If you want,
this is a good time to analyze this completed project and see if you can
create your own flowchart using something like draw.io that I've shown you
before, or just take a piece of paper and a pen and draw out flowchart.
Now, if you want a hint,
then you can head over to the course resources and you'll get taken to the flow
chart that I've created for this program. So spoiler alert,
I'm about to show you that flow chart. So if you don't want to see it
and you want to create your own because it's a relatively simple program,
then pause the video now and complete the challenge by yourself.
Now for everybody else, who's still here, I want to show you,
this is the flow chart I've created to represent this program.
So we start at the beginning. We first show the logo from that file, art.py,
and then we ask for a name input, we ask for their price.
Now we're gonna add the name and the bid into a dictionary with the name as the
key and the bid as the value. Now, once we're done with that,
then we get to ask the user for another input and see if there are any other
users who want to bid. So if they answer yes,
then we're going to clear the screen and we're going to go back to here,
ask for another name, another price, and so on and so forth. But if they say, no,
everybody's done with bidding,
then we're going to call some sort of function that we have,
which is going to loop through our dictionary that was created here and find the
person who had the highest bid value and then declare them as the winner and
print out their bid. So it's a relatively simple program,
at least compared to other things that you've built so far.
So this is the time to pause the video and give it a go.
I'll see you on the next lesson where we'll go through the solution together.