Hey everyone.
So then we have created the buttons and just the working gift.
So how we can make them vote like this one basic way.
So for that one I'm adding a come on here.
That is going to be C or double and me and D.
And now we are adding something like show underscore symbol and X and Y relative to to win this one.
Anita now we need to define that function so define show underscore symbol.
And with X and Y.
So what we do here right now is first we will provide this symbol.
All the symbols that we have created to all the buttons the button that we have created and then we
will check whether this symbol are equal or not.
Now one thing I'm again and again think symbol and they are actually text.
So I need to add here next.
So first of all I will take to global variables.
That is a first.
And do more here that is previous x and previous y the same that we have taken there in the initial
condition.
Now we are going to apply this again.
This one is just whether it is the first card or not.
And these two if there is a first card then there are the coordinates of that one.
So now I will provide every button to symbol sorry every button symbol.
So I will take buttons my library sorted my dictionary that containing all the buttons that I have created.
And the button symbol is containing all these symbols that I shuffle randomly.
So what will I do here.
I will write buttons and first access X and fly so in this way I'm accessing every each of the button.
Now to access is text I was a straight again square brackets and in them text.
This is how I can access the text on button and make them equal to here.
Now you need to pass symbols so buttons symbols and the symbol with every particular accent by I'm getting
because I am making symbols pop again and again whenever I am making X invite so for each value of x
and y I'm hoping something.
So that's how I can add this symbol to any button no symbols are added one more come on.
You need to add here X and Vi and their bus update underscored ideal tests.
So this one just updated dusk so David now we are done with creating the buttons with their particular
symbols.
What after that.
Now a second problem here is if they match then developments in and if they don't then again flip or
not what the Flipboard here I'm referring to.
So basically the flip or I'm here traveling to is just like if remember the caterpillar how the game
will be game over.
I remove the caterpillars or the leaves I just change the color with the same like background.
Now flipping means I will just remove the dust.
Sorry to text and then David in the thing.
So it seems like for people so that so I can flip the buttons old state God's so let's begin the deadman.
One more thing before that one we need to make sure that whether there's a first card already flipped
over or this is the first card.
So if this is the first card then it will stay same light.
So let me show you this one with matchmaker.
So if this is the first card then it will remain in this position.
So this is something I need to take care of.
And if it is second car then only in that condition it will check that whether that's equal or not so
two conditions here.
If this one is first so what will happen in that case.
So if there is no card already done then this my first card is going to be a previous card for the next.
So what will I do.
I will write her previous x equal to x
and previous y equal to y.
I think you will get this thing that what I have done here that it is the first card I will make this
one as the previous because I require this one in the same condition and after that one make first equal
to False.
Otherwise the program will again take this one as my first card.
And again do the same.
Now first is false.
Now it will automatically go for the next commander.
Later on the program again.
So the second come on I added Elif that whether this is a first card or not.
Now at this position we are at this particular position right now.
We have a first card already done and we are going for a second car.
But one more thing here.
What if the user just click the card that is already flipped over.
So what to do at that particular condition so we need to make sure that the user is not clicking the
previous cart.
So that's why I have included.
I live here and have it right here.
Previous X not equal to X or previous Y Not equal to y.
So in that condition it will begin so after that one.
Now we are in this situation that user is clicking any other card except this one.
So I am clicking these these these or these flights.
Now I am in the position when I need to check whether the card is same or not.
So let's check that one.
So first condition if that is not seen.
So if buttons for particular X and Y.
First I will write the previous index and previous y the previous card I have and it's text
is not equal to the buttons that I have right now.
So buttons right.
No I have x y and there next.
So if this is the condition then what will happen in that case.
Just a very small time.
I am not slave for zero point five seconds set so that user cannot see the card.
That is the next day.
And what will I do.
I would just flip them again.
So buttons of previous entries X and previous y previous fly and their text will became empty string.
Now this is the same thing like the changing the color of Caterpillar as the background.
I have just removed the text.
Now few students are thinking that what if I have removed the text.
How will I again get the symbol done so for that cronies.
That's why I have included these four commands in the function because whenever the function sorry button
is cleared it will again call that one and provide the particular button their particular symbol.
This is the reason I have not included them here because in that case was the card is flipped over the
symbol will be go so I hope you understand that thing no.
Hey I have just taken all them in dictionaries and there I have provided them.
Now after that when we are done with this one one more here.
That is extra.
The current cards so buttons and parsed it exclude my wife and their text.
And this unequal to an empty string.
So there we go with that one.
Now we have the as condition so as is automatically the one in which we have.
These are same.
So what will we do in that condition is we will use this visible come on how we will adjust buttons
of previous x and previous y first previous x previous y.
No.
That one day we had previous white and.
Come on.
So the square brackets and come on.
So this is a new way I am using here to access the text and the man because till now we are just writing
them here inside the buttons when we are declaring.
But Wendy Button is already clear.
You can access them by this thing.
So the command will be disabled so once the command is disabled the button will remain in the same position.
Now buttons for current x and y and their command.
So command and that will also be disabled.
There you go.
And after that one when this is a second card make the first one equal to.
So that again the first card will remain in the position when I click that one.
Otherwise that will again do something like No flipping.
So there we go with that one but there is one more thing required in our program.
Like now when you tried to run this one let me have this one one though.
There we go.
When we done that one day you get the error and the added you will get in this line that is here.
We have 42 but if you look at this one then all the things are saying sorry.
Correct.
So how to edit we are getting it.
So there is a very simple concept and a simple answer for this one but little typical to understand
and what that is like.
Look at this one.
Whenever I got any position say zero and zero.
I got this into a button and it will make command for that particular x and y and it will go to the
function that is calling this one and it thinks will work but when another command came when I am clicking
another particular value there.
And this one is calling the x and y.
In that case the same X and Y will value will be transferred to that one.
That's why we are getting here key at 0 0 because the first come on.
That is 0 0.
We are getting zero value for x and zero for Y is going to be parsed again and again to that particular
function because I am clicking the button by using the loops.
I am just creating the button clicking the button is a different thing.
So when I click or create all the buttons here then they are created once but the button command will
work whenever I click them.
It means that they will always be zero 010 so that something how we can resolve them.
One answer for this one is don't use loops just provide 24 times these four commands and provide particular
value for x and y but that will something will make our program too long and it will take a lot of time.
So how to do that.
The answer for that one is what I will do here.
I will add another function to come on I will use to function here one inside of the another what the
first function will do.
It will store all the particular values for x and y that I am getting at that particular instant like
if it is this one is 5 5.
Then it will first store the values 5 and 5 and then it will call the second function with that particular
values 5 and 5.
So I hope you get that one more time seeing again in a very simple way.
Once the buttons are created the all and having the x and y value zero and zero because creating buttons
is a different thing and pressing button is a different thing.
They are not the same but so be sure about that one.
Now how can I add a different function here.
So they already met various methods to our particular functions here and call the function inside that
one.
What I'm using here is a very simple concept that is known as Lambda Lambda functions.
This is a very basic concept and we have not got this one in the course it goes.
This one is very little and did not require much time to understand.
So this is something I can just write lambda and is used only when I need to declare functions in only
one line like lambda provided x and y and write the function z is equal to x plus y so there is something
here we have defined very long functions.
You cannot define very long functions by using lambda.
So you can just define functions in line.
Let me show Dedmon here.
I'm going to define a lambda function and what that will do.
It will first take the value of particular X and store this one in x.
So I'm using the same variable x in x and another valuable y that restored the particular value of y.
So now I have x and y values stored in particular X and Y then the dot nodes mean what will happen then.
So in that one it will just call this function shows symbol.
So I have just righted here something like.
Define that particular function that will take the values and call this one.
But there's something we can do here.
We have to define that function there.
So to define that function in line we use this thing lambda and then X equal to X Y equals Y.
Just this very simple thing and I hope you get this thing that what I have done him and then show symbol
I have called that function.
Now we are ready with a program.
We will get the big cards with very small symbols that we have created him.
Also the symbols here we have created are small.
We have changed the size of card but we will not get these large symbols of the symbol size same.
So now when I run this one I will get by output.
So nothing we have just changed.
We have just added this line and confuse to read it.
This will make no sense like what I am doing here.
I'm just doing X equal to x like worldwide.
But that's very important.
Without that one your program will look what.
Now let's check the walking.
I go to the first car.
And it reminds him I click the second one they disappear this one and let me find a match.
There they go.
When we go to the match we had the same.
They are not changing their position so everything is I believe working fine there we go.
Cesar I think we have this one so we are done with another project here.
And I hope you understand this wondered how the things are working here how the lambda is working here
and this is about discipline you can make them all match lifting to this one.
So this is all about discipline and it's a very little project but contains a lot of topics and lot
of things that makes your things clear.
So thanks for watching.
I would see in the next module.