 Welcome friends, now let's discuss that what is the structure of our study material and practice set. So basically if I talk about practice set, practice set contains of some PDFs. In this PDF you will get 100 plus of questions which are required to build the basic understanding for our basic logic which are required for this basic projects okay so you have to solve this out. Hello friends. If I talk about basic projects folder, this folder consists of three folders okay, whenever you are going to start learning that projects. So the structure of this course is that in that way that you have to first learn the warm up exercise okay so when you are going to learn that warm up exercise and after completing that lecture you just need to open this warm up exercise folder okay and try to solve this blank jupyren notebook okay. In this blank jupyren notebook you will get these two tic-tac-toe game and number guessing game. So after warm up exercise you need to do what? You need to solve these exercises okay which are blank. You have given I have given all the comments which are required okay and you just need to read the comment and what you have to do code according to that comment okay let this jupyren notebook open and I will explain you how. So I have given this for example as a right here import random module what you are going to use okay so according to that lecture you have to work on it okay so this will help you to give you best practice okay and after this warm up exercises what you have to do after this warm up exercises you have to go to you have to come here again this blank jupyren notebook okay so in blank jupyren notebook I have given number guessing game and tic-tac-toe game okay so in this jupyren notebook I have also mentioned what I also I mentioned here comments which are our task which we have to complete to create this game okay and this exercise will help you to be better and improve yourself okay so I hope you are going to practice more and learn more okay so welcome back friends so in this lecture we are going to learn about how you can install jupyren notebook so the best thing is that to install jupyren notebook just you need to install anaconda game so just search anaconda download okay and when you click here just you need to click here on download okay when you download you just need to select which operating system you are using so as I am using basically windows operating system so I click here when you click here there is an exe file start downloading okay I am going to cancel it because I have already have this anaconda exe file so for your you need to download it when you download it this exe file you need to run this exe file okay so when you run this exe file you need to accept some terms and conditions and you will install this anaconda in your computer or laptop after installing anaconda in your laptop or computer you just need to search anaconda navigator and you have to click on anaconda navigator when you click on the anaconda navigator it will take near about one to two minutes to open it okay so you have to wait for some minutes this kind of screens you can see when this anaconda is opening in your laptop so it is taking some time you can skip some minutes okay or some seconds to watch so as you can see here this is the anaconda navigator okay so they are bunch of softwares and other things available here so we just need to open jupyter notebook because for this lecture or with this study with this course we are going to use jupyter notebook as our editor okay so you just need to click here on launch and that jupyter notebook will launch okay so this is how you need to use it in next video we are going to learn about how to use jupyter notebook so i hope you understand about that how to install jupyter in your computer so just let me give a quick recap that you just need to install anaconda okay when you install anaconda you just need to run anaconda navigator in your laptop okay when you open anaconda navigator this type of screen is going to show you then you just need to go and click on jupyter okay notebook when you click on launch you will see a web-based browser okay web-based interface open in your screen in your default browser so welcome back friends so in this lecture i am going to tell you about how to use jupyter notebook okay so after opening jupyter notebook using anaconda navigator you will see this kind of web interface okay where you will see the list of folders and files right so now in this list of folders you need to search or select your folder where you want to save your work so for this course i am going to select udemy python folder where i am going to save all my work done during this course okay i will share this folder with you okay in next video you can see how to download these folders so before we move further let me explain you how to use jupyter notebook okay so whenever you want to create a new jupyter notebook okay you just need to click here on new button when you click on the new button you will see bunch of options just okay so you just need to click here on python 3 when you click on python 3 this new web page open okay which is jupyter notebook basically now here you can see this is called cell okay so in this cell you need to write the code python code which you want to execute okay so for example if i want to print hello world so let me write code for printing hello world so print hello world now so whenever you have done written your code there are two ways to execute this code okay first way is either you can click here on run cell okay when you click on this button the cell will execute and you will see the output here okay so basically this functionality makes jupyter easy to use okay because user doesn't need to switch multiple screens to run the python code and see what's the output of its python code okay so this functionality make user make this jupyter very popular okay and and you can generally see that okay so you need to just write the code here and you need to execute the code and you will see the output here okay apart from this there is another way to execute this cell is control plus enter so when you enter control plus enter you will see this cell will execute okay so there are two ways either you can use run button or you can use control plus enter to run this cell okay now let's discuss more about this button given here okay which are very useful during execution or when we use jupyter notebook this button will help you a lot so let me start with this button okay so this button is used to save okay so basically this button is used to store you can save your work so whenever you write your code and you want to just finish your work and save you can use this button okay if we talk about this button this button gives us extra basically this button can insert cell okay so you can insert this cell or add new cell in your jupyter notebook by using multiple cell we can divide our code into multiple parts and which help us to understand our code working okay so this help us to understand our code logically we can divide our code into multiple steps and we can find that in first step we find this output in second step we find this output okay so we can compare it in next three buttons you can see here these are cut copy and past okay so you can use using this cell you can cut the cell using this button you can copy the cell using this button you can pass to the cell okay now these two arrows are used to move the cell okay so if you want to move your cell up you can use this if you want to move your cell down you can use this button okay now we have already discussed this cell this cell is used to run the or execute the cell okay so if you write some code and if you want to execute that code you can use this button now let me explain you this button okay this button is known as interrupt the car now okay basically what happens whenever we use or write python code okay for example i was using while loop while loop okay so let me give some condition here so if i initialize i equals to zero and i create a condition that this while loop only execute when i is less than 10 okay and you just need to print i value of i and we are increasing the value of i by one after each iteration okay so let me write i equals to i plus 12 so you can see when we execute this cell we find output from 0 to 9 okay because this while loop is going to execute for 10 times and for the i value of 0 to 9 now if we by mistake we made a logical mistake like we never assign or increment the value of i so in this condition what is going to happen in this condition our loop is going to execute for infinity times because this condition is always going to return true okay so as you can see you will see the multiple times your our interpreter is interpreting or our code will executing again and again okay so in this condition we use this okay in this condition whenever we make any mistake which basically it's a logical mistake which put our program into infinity loops so we use this button so when we when you press this button what happened the interruption basically interruption occur okay so the execution of this cell is stopped so this is mostly used when what happened when you go towards infinity loop okay so i hope you understand about this functionalities of jupyter notebook okay so basically this is the basic introduction of jupyter notebook i hope you learned about it and if you encounter any error error or say any difficulties you can google it okay there are bunch of questions available and bunch of very vast community of jupyter notebook users they will answer you so so see you in next lecture till then take care hello friends so in this lecture basically i'm going to tell you how to use or how to easily open that jupyter notebook so just you need to press the windows key and search cmd and open the command prompt okay and in command prompt just write jupyter space notebook then two dash and then again write notebook and after that write dash then write dir means directory tools to see okay capital C and call it and enter this is how you can easily the this is the very easiest way to open jupyter notebook okay this is how you can open the jupyter notebook very basic and easiest way okay i hope you understand i will give this this command in an article where you can find it okay thank you welcome back friends so in this lecture we are going to discuss about what is number guessing game okay so before we create this number guessing game let's play this game to understand about its functionality so basically this game is very simple so what happened in this game is computer generate a number between 1 to 100 and user need to find or guess the number generated by the computer easy so let's play and enjoy this game so let me run this code so i have two options as we have discussed earlier that i i can click on the run button or you i can use control plus enter so when you hit control plus enter this will execute okay now so first what we get we get a number message welcome to the number guessing game and the number range between 1 to 100 now so at this position at this particular event what happened is computer has already generated a number okay so we what we have to do is we have to find that or guess that number so let's guess let's guess 40 so we got a message that this number is too low then guess again so let's guess 50 again we got a message that this number is too low so let's guess 70 again we got a message that this number is too low means it neither be a let's write 90 it's too high okay so we can find out that our number which we have to guess is greater than 70 and less than 90 because we got a message too high so now let's guess 80 80 is too low it means we can say that the number which we have to guess is greater than 80 and lower than 90 so it basically let's try 85 okay 85 is too low also so near try between 87 it's too low again so let's try 88 oops yes so we find out the number so this is how this game works okay welcome back friends so in this lecture we are going to perform some warm up exercise for number guessing game basically these are some things which we are going to use to create number guessing game so before we are going to create that game let's understand or recap this the logics and how we can use if a statement as a statement what is if l if a statement how to implement while loop in python and how to get input from the user and how to import modules and how we can use modules functions and method in our program so let's try or let's start this thing okay so basically what we're going if I talk about random module so basically what why we are using this random module because we want to generate a random number okay so basically to generate a random number we are using random range okay random range method which is basically we are using this method and what this method can do basically this method takes two argument okay so first argument is starting range and the second one is stop where to stop okay so basically what happens whenever you run this code okay so what we are doing is basically is just we in first line we are importing random module and from random module what we are going to use we are using random range method okay so basically whatever the value this method will return we are going to assigning it we are going to assign it into this variable known as n okay and we are going to print it so let have a look that how this is going to execute okay so when we execute this we get 29 okay so let's execute again again and see we will get always a random number okay as you can see so basically we are using this random range method to generate a random number in between one two hundred okay now comes let's come to time model okay so basically why we are using time model because we want a two second delay okay and in our code okay so basically for two second delay what we are using we are using slip function okay so basically in slip function what we need to do is we need to mention or we need to pass argument for example if i write it here too so basically what is going to happen let's see this is going to give a two second delay in our program execution as you can see here see again it just printed start and after printing start for two after two second he is going to print stop okay so how to use this we just need to import the time model by writing import keyword and writing the model name time and when we import the time model then we are using what time dot slip this slip function will help us to put a delay okay in our execution if i put five here then then see what happens we got a print we got a print start and after five second we this going to print stop okay i hope you understand how this slip function work okay now let's come to how to take input from the user okay so basically whenever you want to take any input from the user we use input method okay now how this method works so basically we need to write input and a message which user want we want to display to the user okay so let's let me run this cool okay and so you can see this type of thing okay so here this is our math message which one we want to see during the execution of the code and so basically what is going to happen here whenever user enter a number it's going to assign it to this number one variable okay number one variable okay so if i write 20 then what's going to happen it's going to assign to the num but you have to see one thing okay whenever you use input method it always gives value in string format okay string data type okay so as you can see here we as we as i give number 20 okay here it will print 20 but whenever when we see the type of number one number one we find that that number one belongs to class str it means the value which this number one is holding is what kind of it's kind of basically it's belong to string okay so now what we need to do this how to scoop basically for this problem we use typecasting okay so basically what is typecasting we type convert the type of the input so basically the user gives us a value for example let's see again if i enter 20 what will happen see this input method will return as a value in form of string so basically when user enter 20 so what this value gives this input method gives value 20 and then we convert this 20 into a integer type okay and then assign it to the number one okay so when i hope you understand how this work okay so let me undo this so basically what is going to happen here after execution this line the number one or we can say the number one variable holds a integer value okay so let if we print that integer value or the number one we get our value and when we find the type of this number one we will find that that number one belongs to integer class okay now next is our while loop so i hope that you know how to use while loop basically so whenever you want to use while loop you just need to mention while keyword and then you have to write a condition here which is based on any code logic which you want to implement so basically i have using here a count variable okay so this count variable what he's doing we are assigning it by default by one okay so what is going to do basically what happens when interpreter execute this line it basically assign a variable count and assign a number one okay so basically the value of count is one now what is going to happen when this while loop execute it will check this condition if this condition returns true then this body is going to execute okay so for each iteration what will happen for each iteration this condition is going to be checked okay if this condition returns true then this going this body is going to execute otherwise if this condition returns false then what will happen this body or this while loop will terminate ok so let's see how this work as you can see what output we got basically we are if we see we can see this while loop is going to execute for four times ok why it's going to execute for four times because the value of count is it's it starts from one and goes to four and when we encounter this condition for example in after fourth iteration the value of count become five ok when the value of count become five you can see this condition is going to return false ok and when this condition returns false this while loop is going to terminate and going to print outside while ok this message I hope you understand how this value is working now and what this role of count is here basically count gives us basically this what we can say this condition is depending on count value ok so for each iteration what we are going to do we are increasing the value of count so after each iteration what will happen this value of count will increase by one and so when we completed our fourth iteration the value of count becomes five and then five then the value become five then this condition will return false and then this condition when this condition written for us this while loop is going to terminate ok now let's come to using if else statement so basically what happens in if else statement interpreters look for this condition if condition returns true what will happen this part is only going to execute ok and else part is not going to execute ok so interpreter escape escape this part if this condition is true so let's say we assign i equals to 10 and this here we have mentioned a condition i is less than 20 so let's see what happened as we know what will happen because this condition is going to return true so this part is going to execute ok but what if if I change the value of i to 30 or 60 then the else part is going to execute why because this condition have written us false ok and why it returns false because value of i is 60 and 60 is higher than or greater than 20 ok but here we have written 60 less than 20 so that's why we are going to get up what we are going to get we are going to get false and when we get false this else part is going to execute ok I hope you understand now let's see how this if alif works ok what I want to say alif if alif statement so basically let's see how this alif if alif statement works ok so basically what happened it's similar like we have written or if you have studied about if else if in see language if you study about this logic in see language this like this logic is similar here also but in python we are instead of using else if we are using alif ok now let's understand its execution ok so basically what happened we use multiple conditions ok so if this condition which belongs to if if returns true then what is going to happen if this condition is true then this part only this part is going to execute and the rest of the part is going to terminate ok but what if this condition for God falls and this condition got true in this condition what will happen this part is going to execute ok only this part alif part and what is this both condition God falls then this else part going to execute ok so let's see this practically ok so let me put the value of eyes 10 so in this condition what we can get the output we are going to get this one ok why because we got this condition ok if I put something 60 then what will happen we are going to execute or interpreter is going to execute this part because this condition God or true ok what if we put something like ok this condition never going to accept it else ok so let me write here something equals to 20 at this time what going to happen at this time this part is going to happen ok run ok executed why because these two condition is God falls why because value of I is what value of I 60 so this condition will return falls then after interpreter search for this condition and this condition also God falls so when this condition God falls what will run this else part ok so I hope you understand about all this concept ok and so see you in next lecture where we are going to create number guessing game thank you welcome back friend so in this lecture we are going to develop number guessing game using python so let's begin so I have already written some task which we need to require to achieve to achieve our goal ok so let's do let's achieve our task one by one so we will we will reach to our final vote which is number guessing game ok so first what we need to do we need to import random and time model ok so for importing whenever we want to import any model just we need to write what import keyword ok so we write import keyword and then name of the model which we want to import ok so we want to import random so we are going to write random after that I also want to import time so let's copy this again so import time ok so first task was complete we have imported random module and time model now second one second task was that create a random number from range of range between 1 to 100 ok so to create a random number in between range 1 to 100 what we are going to do so basically we are going to use random range method ok so let me write this first then we will understand it so basically what we are doing I was creating a variable and in which we are going to store our unique or random number ok so first of all I'm going to create basically what we are using to create a random number we are using random module and in random model basically we have an and method known as random range ok so basically what random range do random range gives us and what I say a unique value in between given range ok so we are using this matter random range method so let me write this range ok and as an argument we have to pass two value ok so first one is starting range and from sec second argument was ending range ok so basically what we want we want a range between 1 to 100 ok so we have given the range here so this line basically what this line do by interpreter hit this line interpreter will get an a sign a random number in N ok now write a welcome message so so let write a welcome message so let me write print so this message is going to be as shown as a welcome message ok so let me write a welcome to the number game ok number guessing it ok now give two second delay so basically what we want we want that whenever user execute this code so user get this line welcome to the number guessing game and we after this line our program got delay two second delay or we can say we want our program to stop for two second for that we are using time model ok so time model have a function called sleep so basically this sleep function what to if I put two here so basically our program is going to for sleep for two seconds ok if I put five then our program execution is going to sleep for five seconds ok so this argument this which argument we pass it's depend where so let me write to so we are going basically what will going to happen when we put two here as an argument about execution of the code is going to sleep for two second ok now take a user input to enter a number ok so basically what we need us we need a guess from the user ok for so user is going to give us an input for taking input we are you always use input method so let me write so basically what we're using we are using input method to take a number ok so let me give a message to the user that a guess a number guess a number ok so user will guess a number now input will return us a value in form of string ok always remember when whenever we use input it always written that input in form of string so basically we need to convert its type because we need an integer number ok so we use typecasting here ok so this input will give us string and then we'll convert that string into integer and after in converting that string into integer we are going to store this value in a variable which is guess ok so I've created a variable guess ok so I hope you have understood this execution how it's going to work now so the main part or the main logic starts here ok so whatever your what is our task use while loop and create a condition which execute while loop till the both number not become equal ok so basically what we are going to do we are going to use while loop here ok so I have to create a condition which gives basically what this condition to this condition always check ok so let me write n is not equals to guess ok so whenever this condition written true this loop is going to execute ok and we also want this because we want that this loop will execute again and again until our condition this condition is not going to return true ok now so we have already covered this part now let's talk about next task so our next task is what so if guess is a smaller than n ok so we need to create an condition here and the condition is what so basically we want what we have we are going to use we are going to use if condition if a statement ok so let me write if guess is less than n ok so whenever this condition occur we are going to print that the number which user has guess is too low ok which will give user an idea that he has to or she has to select a higher number than this one ok now let's give another chance to ask to user to guess a new number ok so let me write this one again guess equals to int then input and input let us write that guess again ok because the number user has guessed is smaller ok so guess again now after writing this code what is our next task our next next task is if guess is greater than ok so if guess is greater than what we need to do so let's use aleph ok so aleph aleph is basically aleph ok but in python we don't use aleph if we use aleph ok so aleph guess is greater than n ok so for this we are going to print and what a message which is which is going to say user too high ok and after getting this message let's give a user and another chance guess is equals to int input and let's write guess again ok so basically what is going to happen here uh we are asking user basically we are asking user a guess ok when user is going to give a number then we are going to compare it ok so if they are not equal then this body is going to execute ok for first and then first we check if the guess is less than n then we are going to print too low and then again we are asking user to interrupt guess his guess again ok after that what we are doing is we are again checking it if guess is lower or greater than n then we are going to print the message too high and we are giving another chance to user to guess again ok now if guess is equal to n terminate the while ok so whenever you have to terminate any loop we use break statement I hope you know that ok so we are going to use else part else statement and in else estimate we are going to use break ok so what is going to happen whenever if user make a guess and which guess is for example if guess got equals to what and then it is going to be break ok ok and so this task we have completed here ok and now let me write final message ok so final message is what so let me write print this final message is going to execute when what when the guess and the random generated number is going to equal ok so at that time this guess is going to be basically this basically this final message is going to be printed so what we want to print we want to print some stars and then in between the stars we want to print you guess the right guess it right with it ok so finally we have completed our task now let's run this code ok so here you can say welcome to the number guessing game guess a number so let me guess 50 so 50 is too high so let me guess 30 so 30 is too low so basically what we can conclude that our number which we have to guess is less than 50 and higher than 30 so let me guess 40 ok so 40 is too low again it means our number is going in between 40 and 50 so let me write 55 ok finally we won ok so number which we have to guess is 45 I hope you understand this logic and welcome back friends so in this lecture we are going to add some more functionality in our number guessing game like user have only five attempt to guess the right numbers and after each guess if user is wrong user will get a message which tells him about number of attempts left and if user used all its attempt and not guess the right number then user will get a message bad luck try again ok so let's code this functionality in our code ok so but before that let me copy our code and paste it into new cell now now so basically what we have to do we have to give user only five guess five attempts to guess ok now for that what we have to do let's first print this message to the user so user will know get to know that he has only five attempts ok so let me write it here you have you have only five attempts to guess now ok so attempts to guess ok so this line will help user to understand or that he has only five attempts to guess now I am using here slash n basically what is this slash n is a new line character ok so basically this new line character is what going to do whenever interpreter get this new line character it is going to switch the line and print this line ok now as you all know we are using slave function because we want to second delay in our code execution ok now so ok now for our main functionality which we are going to add is that user only have how many guesses attempt only five ok so for that we are using a counter variable ok so basically what counter variable is going to do counter variable will help us to count the user number of guesses ok so let's me create a count variable so write count let's assign it one ok so basically why we are assigning it one because user already have guessed one time ok now so whenever or wherever is going user is going to count or guess the number we need to increase the value of count by one so let me write count plus equals to one ok and here is also user is going to count so let guess so let me increase right here count plus equals to one so whenever user is going to guess we are going to increase the count by one ok now and one more thing we also want that whenever user guess the wrong number user will get a message so let me print that message ok so basically what message tells this message will tell basically what that user have this much amount of left ok so you have so for this we are using placeholder ok and format method I you have now basically what this going to is whatever message the value we are going to give it here it's going to print here ok so let me write here five minus count so while we are writing five minus count let's understand let's understand this user have already guessed a number ok which is too low ok if this number is too low then this message is going to print and for that time you this value of count is one so five minus one is it will return four and this four is going to print here so basically what message user will get that you have four attempts left I hope you understand how this format is working ok so let me undo this now let me copy this line because we know that we have to print this line when user guess a number too high ok so whenever user guess a number which is higher higher than a guess number then what is going to print too high and after that user will get this message you have this number of attempts left ok and after that user will get a message guess again ok now let's run this code I think we have achieved but before running this code executing this code let me write one more thing and which is now basically write what is going to happen here we need to use if else a statement because this while loop which is going to terminate on two condition ok let me tell you ok I never mentioned this condition and I have to mention this condition ok so this is the condition is when count is less than five ok so basically we are using logical operator here and because we want this if this two condition is true then this loop is going to execute if what and if we got any of these two condition falls this loop is going to terminate ok so basically why we are using this condition because we only want to give user five chance or five attempts to guess the right number ok so basically what will happen after each guess user will met what we are going to increase the value of discount ok so whenever user will guess a number we are going to increase the number of count by one ok so what is going to happen whenever user used all its five attempt this condition will return false and when this condition return false this loop is going to terminate ok so I hope you understand what why I write this condition here now I think we have ok so we have created and now let's discuss why we need if else here ok so basically why we need if else here because this while loop depends on two condition ok and this while loop is going to terminate on two condition and the first condition is what when user gets the right number ok when user is the user guess and the number which is randomly generated become equal then this loop is going to terminate and the second condition is when the number of count or we can say the number of count equals to five or when user used its all guesses ok then this condition will terminate the loop so for that we need to write here ok so whenever this loop is terminate this line is going to execute and for this line we need to write a condition so if n equals to equals to guess what will happen they are going to print this line ok that you guessed it right and if user guess the user used it's all what I say all attempts so this line is going to print what line that bad luck try again I think we have achieved all our goals now let's run this group so we get a message welcome to the number guessing game you have only five attempts to guess ok now guess a number so I hope let's check ok so before playing this game let's check this game ok so now let's check how many attempts this game will give to the user ok so for this I'm going to make same guess again and again for example 10 so he tells me that this games tells me that you guessed the to the number you have guessed which is 10 and you guessed your guest number is too low and you have four attempts left ok now let me guess it again 10 so now you can see here you will you will get the message that you have three attempts left ok let me guess 10 again then you can see here we get a message that you have two attempts left let me guess 10 again then I got a message that you have one attempt left ok so we got it now so this game is going to give user only how many attempts five attempts ok so we have achieved this functionality now let's play or run this game and this time we will win ok so let me guess the number it's 15 ok so 50 is too low so I think it's 80 80 is too high so we can assume that our number is live between which number we have to find is live between 50 and 80 ok so let me write it again guess it again so 50 ok so what we can it's maybe 70 ok 70 is too high it means let's try 65 65 is too high let's try 60 oops I lose this game ok so I hope you know I hope that you understand that how this game work and how to create this game and I hope you understand the logic behind the why we use this counter variable and why we use this condition so welcome back friends so in this model we are going to learn how to create two player tic-tac-toe game ok so before learning this game let's play this game enjoy ok and after playing this game then we are going to learn some basics of this game and then we are going to create this game ok so let me run this code ok so here this is our basically tic-tac-toe grid ok now basically there are two players ok first one is x and second player is o so this time this is the x turn ok so x have to put some position ok or place so if x want to update this position or x want this position ok so he has to put he has to write he has to give that poor place is 7 so here you can see we got x here now it's second player turns ok which is o so o want this place to be occupied so so o choose 9 so now you can see that our grid is going to update after each value we are going to choose for each hit play so now let me write this one so x have mentioned here now what is going to happen now only to stop this stop x to winning this game ok so he is going to put o at place 4 ok now it's x turn so x is going to take three place third place here and now o got confused because why because if o take this place then x is going to take this place and x is going to win if o take this place then x deck takes this place after o's turn and x is going to win so o has no choice so is going to write 5 and now it's x turn so x is going to write o take second position or second place now so you got this we get a message that games game over and x 4 ok so this is how this tic-tac 2 works ok so in upcoming lectures we are going to learn some basic concept or basic logics of python and when when we understand all those logics then we are going to merge all those logics and we are going to create this tic-tac-toe game ok so till then take care and see you in next lecture welcome back friends so in this lecture we are going to discuss about some basic concept which we are required to create tic-tac-toe game ok so first of all let's understand what is python dictionary ok so in the python dictionaries are used to store data values in form of key value pairs ok so basically let me let me clear you that whenever we create python dictionary we always use item or store item in form of key value pair ok so basically what is key value pair basically we use what we use column to separate the key value in left hand side we mentioned keys and on the right hand side we mentioned values ok when we create dictionary you will get to understand this thing very clearly ok now and if we talk about what is dictionary so basically dictionary is a collection which is ordered changeable and does not allow duplicates ok so basically what is dictionary so basically dictionary is a collection which is ordered which is changeable you can change it and but one thing is that which makes dictionary very useful that it does not allow duplicates values ok so let's see how to create dictionary so whenever you have to create a dictionary you just need to first you have to mention what I said mention a variable for example if I have to create a dictionary I mention a very I have created a variable known as dictionary one and now I was going to use curly braces ok so to create dictionary we always use curly braces and in this dictionary in this curly braces we give item in form of key value pairs ok so let me create a dictionary for example let's name this dictionary as a dictionary five and let me give some values to it ok so basically let me give first one and this is basically this is our key one and the corresponding value of one is one ok in integer form then we use comma to separate the items of the dictionary so let me create another item ok which keys is two and its value is two ok so I hope you understand that how to create dictionary and how to add items in it ok so basically I what I have to do is I have to mention here a key so let me three colon and the corresponding value is three ok now this is how you create a dictionary so let me print this dictionary so when we execute this code you we will see how a dictionary look like so you can see when you print dictionary five you will get one in form of this is the key and this is the value if we talk about this item this is the key and this is its value if we talk about this item so this is three is a key and this three in form of integer is an item ok now so basically why we are learning dictionary concept because when we use tic-tac when we run or when we create this tic-tac-toe game we are going to use basically this dictionary to store the position of x and y or x and 0 ok let me show you I have what I was talking about so basically I was talking about this concept ok so we are going to use dictionary to store the value of these positions ok so basically if you have gone through this article which I have written this here so basically when we play tic-tac-toe game we use three by three x grid ok now let's go to again bomb up x side ok so here we are going to use dictionary as you can see here keys in our in form of string ok so here's I have written a seven but I use quotation mark so which basically makes this seven in for as a string ok and all the value corresponding to the keys are void space so basically the values which you have seen here are the void spaces ok so let me execute this quote what if if I write something like that ok we will discuss this later on ok this concept now learn how to apply loop ok so whenever you have to apply loop so basically generally we use for loop ok so let me write for I in or let's say item in ok one more thing is that whenever you are going to apply loop on dictionary ok so let me write dictionary five and let me just print the value of key key in each iteration ok so when let me clear this one thing whenever you are going to apply for loop on a dictionary all the value at this return ok at this condition the value we get is only the key ok of that dictionaries so let me write this ok so when we execute when I execute you will understand ok so here when we apply this for loop on dictionary five what we get each iteration we only we get what the value of the name of the key which present which are present in the dictionary five ok I hope you understand about this now how to access learn how to access the dictionary what I say dictionary is items ok so to access dictionary item we always use what we always use keys ok so let me write this basically let me correct this items value ok so whenever you have to access the items value of a dictionary how we code basically we just write print ok and then we mentioned the dictionary name so for example here our dictionary is dictionary one dictionary zero one and then we use square brackets and write or use key so what this code is going to return this code is going to return us the corresponding value of this key seven ok so let me execute this code you will get that we got g as same as just imagine just let me write if I mention here something like a two or three so you can guess what value we are going to get yes we are going to get c you can see this ok so this is how we can access the dictionaries items value ok using key name ok now how to create empty list so creating empty list is very easy ok you just need to mention a variable ok variable name here I have written a name board underscore keys and to create empty list you just need to write what this is square brackets ok opening square bracket and closing square bracket so basically what this code will do this will generate a empty list ok let me write this ok so when we print board underscore keys so what we are going to get we are going to get a empty list what if if I mention here one then we are going to get a list which has one element ok so basically let's understand how to create empty list to create empty list we just write a variable name and then we mention use square brackets ok now now welcome back in the exercise of tic-tac-toe part 2 so let's learn that how we can append the dictionaries keys into a list so basically we have generated a empty list as you know here as you can see here basically now what we are going to do basically we are going to use the board dictionary ok so what we are going to do basically we are going to apply the for loop on the board the board dictionary ok so basically the board dictionary is what let me see so here this is our the board dictionary ok so what we are going to do basically we are going to just going to apply the for loop on this board dictionary let me copy this so we will understand it better ok so basically what we are going to is basically we want to copy or we want to append all the keys of this dictionary the board dictionary into our this list okay so how we are going to achieve this so basically we are going to apply the for loop on this dictionary the name board okay and what this dictionary is going to return if we are going to apply this for loop on this dictionary so basically each iteration we will get the key well basically this key where variable is going to hold up the value of key one by one okay so let me write okay so basically what is going to happen here we are just going to apply the for loop on this the board dictionary and when what we are going to get we are going to get in each iteration we are going to get these keys one by one into this key variable okay and when we get this key values in this key value key variable then what we are going to do is we are going to append we are going to perform append method okay so basically this append method is a method of key and basically it belongs to the list okay so basically this append method is a method of list okay so basically what this append method will do this append method will append or we can say add the given item in the list at the last position okay so let me see okay so let's run this code and you will see it when we run this code we will got okay let me print so we got clear so let me print here okay so what we are going to do basically we are going to print here and each print basically what's going to happen here from each iteration we are going to get to know how over this board key board underscore keys list looks like okay so boards underscore keys okay so let me execute this so you can see this is our empty key oh sorry empty list and from each iteration what is going to happen basically in each iteration what is going to happen is we are just going to insert or add or we can say append the value of key which is the dictionary keys well okay so basically what we are going to append or add in this list the value of the key names okay so you can see for each iteration what is going to happen in each iteration the value of the key or we can set the name of the key is going to insert at the last position of the list in each iteration okay so I hope you have cleared this concept okay now let's switch to the next concept okay so learn how to print multiple message or string or variables and message both together okay okay so this is very basic thing so whenever you have two messages or the two variables to print for example a equals 200 and b equals to 200 okay now what you have to do you have to print these values okay so basically you have multiple values okay so so how you can print it so basically you generally you can use a comma and b so when you execute this you will print this two values of the okay values or the variables value of this variables a and b now what if if you have to mention some message okay here like for example value value of a colon a okay so basically what is going to happen in this time when you execute this you will get this message printed and after that printing this message interpreter will print the value of a okay looks like this value of a colon 100 okay what if you have to put print multiple for example some multiple messages like this and values okay so how you can use this print so we you can write this like value of a then colon and then what you are going to do variable a then you can again use comma and again you write the message that which is value of b together you can use colon and b okay now when you execute this quote you will get this message in this format okay so this is how you can use or you can print multiple messages and variable in one single using print okay I hope you understand this okay now learn how to create tic-tac-toe board okay or grade of three by three so basically we are generally using what just using some logic of how you can print okay so basically we are just printing what let me see we are just printing a white space here okay so basically what is our task we have to create this kind of board okay this kind of okay and how we are going to achieve this we are going to just use some lines like this some dash using plus dash okay so let me see how let me understand how let me explain how to use this okay so basically what we want in first line okay we need a white space so basically what we have done we gave a white spacing as a string okay we created double quotes or you can either use single quotation mark okay so here I use single double quotation and I gave a white space so basically what will happen when you write okay let me understand let me explain this from the very basic so basic okay if I write something like this what is going to print obviously it's going to print a white space okay here this is the white space now what if if I want to print at this line okay so how we are going to do this either you can use comma or you can use plus sign okay basically why you are using plus sign because we know that that concept okay what will happen if we use this plus sign in between two string so let me explain this a and plus b so what is going to be basically it's going to concatenate these two strings okay a b okay I hope you understand this so basically what we want to concatenate here a white space and a parallel line okay now so basically we want to print this so you got this okay now if I have to also if I want to add a white space again so what we can do we use plus sign and use double quotation marks and give white space and if I want another line then why how we are going to do this double quotation marks and this time white space we need this this okay and other white space okay so this is how we have created the first line now what if if I want to create a new line about let's try and learn how you can create this line okay so you just need simply write print then afterwards what we want basically we want a dash okay so we are going to give it a dash then after that dash what we want we want a plus sign then we are going to just use this plus sign for concatenation now now we need to either we can use double quotation or a single quotation here and then we need we are going to write plus okay now we are using concatenate plus for concatenation and we need dash then afterwards we need plus sign and then we need dash okay so for that what we are going to do we use con here we need a dash okay so we dash then we need to write plus for concatenation then we are going to use double quotation marks and then write plus then again we write plus and this time we need what we need dash okay so when you execute this code you will get these two lines okay similarly if you copy pass this all codes you will get what these two lines okay so basically we have churned it we have created four lines we need another one so this is how you are going to print or this is how you are going to create our what I say grid okay three by three x by three okay grid grid now and why we are creating this grid because when we going to play this game tic-tac-toe so we need a grid okay so for this grid for that grid we are going to use this concept okay we can either understand this concept by using so let's now use something import it's okay so let me import time okay if you so let me write this here I basically what I am going to do we are I am going to use that sleeve function okay that sleeve function will what this sleeve function will give us that sleeve function will give us some amount of delay okay and that's amount of delay basically the amount which we are going to mention it so for example if I want to second delay the how I am going to write this time dot sleeve and brackets I am going to give it to okay and let me copy pass this all here so you are going to understand that how this is this box is going to print okay let's execute this you can see what we got okay module time is not okay okay if we made a spelling mistake here you can see this is the first line this is the second line printing then third line then fourth line and this one is fifth line okay and our grid is ready right now let's move to next thing so learn how to use dictionary item to print okay so now this time what we are going to learn that how we are going to print this dictionary's item okay because we are going to use this dictionary to store the value of these positions okay so whenever user put here x for example in this box if user put x and in this box user put 0 so we are going to update our dictionary according to that okay and then we are going to print this grid again and again so we will get the value of we will get to know that what position has taken and where you have to where user have to use or need to put his chance now so basically what you are going to do is we are going to learn how we are going to use dictionary items to print okay items value let me correct this items value so for example if i have to print this x okay the value basically this value is corresponding has a key okay which key seven so i have to write here okay what i have to write here i have to write dictionary zero one square bracket and then in this square bracket i have to pass key seven so let me run this code and you will see something okay so we are we have updated that this value of x what if if i have to use what i have to print this value okay corresponding nine where i have to print i have to print here so where i have to make changes i have to make changes here okay so let me write this dictionary zero one and then what i have to do is i have to write the key value which i want to print here so basically i want to print nine so let me write nine okay so you this is how you are we are going to use this concept during the creation of tic-tac-toe game okay okay let me explain what if i want to print this all values okay in this dictionary so how i'm going to do this i'm going to write here okay so dictionary zero one and corresponding key which corresponding key is eight okay so we are getting what basically this is the key eight is holding the value void space okay so we are getting void space okay so let me write this all here and we are going to print this okay so let me write this so dictionary one and then square bracket and then i have to write four why i'm writing four because this position belongs to four number key okay and the corresponding the corresponding to this key what value we have x okay now just let me write this thing so just i will i'm going to copy it and paste it where i have to write it so instead of four i have to write five and at this position i have to write what i have to write six okay similarly here i have to make changes in this position i have to write three for this position i have to write what any ss yes two and for this position i have to write where okay when i execute this we will see this is how we are going to update our tic-tac-toe board in each iteration okay okay so i hope you understand that how to access the value of dictionary's items using key okay i hope you understand this now welcome friends in this third part of warm-up exercise of tic-tac-toe so this part is going to be very important because in this lecture we are going to learn some important logics which we are going to use in our game so let's start so our first logic is that we are going to learn how to check empty places in tic-tac-toe three by three grid and insert the value okay so actually if you look at the above cell which we have discussed in last lecture you will find that at the time what we are doing is basically we are hard coding the values and printing it okay so basically what we are doing is we are putting some value here and we are printing it okay so if i doesn't want this x to be here i just execute this and this x is gone if i want the x here then i have to put x here and execute this and i got x here so basically this is called the concept of hard coding hard coding means doing with your hands or we are on without doing any using any logics okay so now let's understand about what we have to learn in this thing okay so basically what we have to learn that how to take input okay input position from the player and check the position is empty or not if we found empty position then we are need to put x or o at this place okay so basically what we have to do is as you can see here basically when user give you something give you a position okay whatever what happens when tic-tac-toe game run so basically our game wants and position okay where you have to put the x or o so basically what you have to do you have to just take the position from the user and you then you have to check in this dictionary that this position is empty or holding some value for example if user gives us 8 okay so we take that 8 position and search in this dictionary with using 8 key okay and then we will find if this place is empty okay means white space then we are going to put the value here if this place is not empty first of course this place hold a value o okay so if this place is not empty then we are going to do what we are going to send a message to the user that that place is already taken select another position okay I hope you understand that what I want to say okay now so let's understand how we can do this okay for that what we have to do we just need to use if else statement okay so basically when we use if else statement what we are going to do here okay before using if else statement let's understand how we are going to take the value from the user so basically we are just using print function where you we are going to print the message okay and after that message what is going to happen we are using input method okay so basically when user gives something for example any position what is going to happen when user enter the position or a number or a place okay so what is going to happen it's going to store in this variable move and what is going to happen when we are going to check this condition so basically what happens for example if user gives us a place let's say 8 okay so what is going to happen this 8 is going to be initialized or stored in assigned to the move variable and then what will happen when we check this condition basically what we are what we are doing here we are just checking that dictionary one and the respected key which user has given us okay so let's say dictionary one and this move will has value 8 so if this condition true means if dictionary one key 8 has empty place or wide space then what is going to happen then this going to happen what then dictionary one move means 8 is going to hold this value okay so this value is what this value is turn and turn is basically in this code basically we have assigned this turn variable equals to x okay now let's understand and let's execute this code you will understand more okay when we execute this so let me execute this so when you execute this code what we are going to see we are going to see grid why we are going to see this grid because we have written here okay return the code to see the grid okay now basically we have declared a variable called turn okay which is x so what we are going to use basically this execution is going for player x okay so when x so basically what message we are going to get okay here what we are using we are using conkinetation okay so in print we are doing conkinetation what conkinetation we are doing basically we are writing a first message it's your turn and the value of turn basically the value of turn is x and move with move to which place okay so basically this line is used to ask the user that it's your turn x and move to which place okay so for example if x want to move this place here okay where here so how he can move he just need to enter eight okay and when he print or he gives eight what will happen when you print this dictionary again that print this code you will see the update in the dictionary okay so you can see what this happened here we put the basically this code will execute perfectly that use computer is asking for it's your turn x move your place then user gives a value eight then what happens this x comes at the place of eight okay now how we can change the players after every move this move is only for x okay now we have to do what we have to move the we have to change the move every time okay so how we are going to do this for that we are going to use for loop okay let me write this so let me copy this and then you will understand how we are going to use okay so now for this I am going to create a for loop just wait okay so we are going to put a whole this code into for loop and here I am just going to execute this for loop for three times only or four times let's say so for in range actually just I want to explain you how this for loop executed okay so just we actually we are wanting what we are wanted that just we want this loop to execute for four times okay now what is going to happen let's see let's change some value of this dictionary so where is this dictionary okay let me copy this thing this is our dictionary and this is let me execute this then you will understand so so basically what changes we have made we empty some spaces here only position seven position one has x and position six and position three has okay now what is our message is asking our message is asking it's your turn x move to which place okay so if for example x select nine place okay so nine basically is this place okay so what that let's see what will happen okay so you can see here we got x here okay now what he is going to do okay we are not changing the position we had some mistake here and what mistake we have done okay this line is not executing actually why this line is not executing if turns is equal to x then oh so what is here turns okay let me change this thing basically what is happening we are assigning each iteration for each iteration we are assigning this turning equals to x that's why we are got getting this problem okay so let me cut this code from here and put it here okay now when we execute it it will execute perfectly okay so let's see here just wait a minute okay this is our grid now it's x turns so x select nine when you are you can see this time our message got changed okay it's your turn zero or oh move to which place okay so if oh wants to move this place okay so then for this place what he has to do user has to write four and then you can see easily what will happen here oh comes okay now it's whose turn it's x turn so x has to puts for example here okay if x wants to put x at which position at two position so he has to write two then x will come here and now what is happening here we got another message one of which tells it's your turn zero or oh move to which place okay so now for example if user uh if oh wants to move at this place which place is fifth then user have to put basically why this for loop uh basically why execution of this code is stopped this cause we use for loop with range four so basically this for this for loop is only going to execute for four times okay now let's understand the logic behind how we are changing the turns here how we are changing this message again and again so basically what is going to happen here initially we have declared the turn is equals to x okay so basically the value uh basically what will happen the turn variable has this value okay now what will happen after the execution of this thing this will print then this going to be print it's your turn okay then right now the value of turn is what x so here what we are going to get we are going to get this message it's your turn x move to which place okay now user enter something uh let's discuss with this example okay so now user has enter nine okay so when user enter nine what will happen move move will assign to the nine and what is going to happen we are going to check in dictionary one that move the key move is empty or not if key move is empty okay so he basically this key basically belongs to move belongs to nine so if key nine is the corresponding value of key nine is empty or white space then what is going to happen then that dictionary one nine is going to assign the value of turns which is x now after what is going to happen after this part after this part this thing is going to happen so after this execution what is going to happen if turns equals to equals to x if turns is equals to x then what is going to happen then this condition is written true then turn is going to assign to the new value which is oh okay this is how this execution works in next time what is going to happen this is only if this happens in first iteration in next iteration what is going to happen in next iteration this whole thing is going to print again in this time as we know that right now the value of turn is becoming is have is become zero or oh so now what message we are going to get it's your turn zero or oh move to which place okay as you can see here after x what we got we got this message it's your turns go move to which place now what is going to happen if user enter four then same thing is going to happen again that this using this condition we are going to check if the position if the key four is empty if key four is empty then we are going to initialize that key four in dictionary one with the value of turn and here for this iteration the value of turn is zero okay or oh we can say now after that what will happen then same thing happens if value of x or value of turn is what for this iteration what is the value of turn is value of turn is right now it's oh okay so this condition is going to false when this condition is going to false then as part is going to execute in x part we have written that turn is equals to x okay so now what is going to happen now the value of turn is going to initialize x okay this is how this iteration work again and again and now this follow up execute with the value of turn is x okay then whole thing will print again then it will again ask it's your turn next move to which place as you can see here in third iteration what is going to happen this chart is going to print then this is this message is going to print it's your turn x move to which place okay then you enter a user enter to and what will happen add the position to this x is going to be print and next move what will happen for next iteration what is going to happen the value of what the value of turn becomes oh and then this message is going to print again it's your turn oh move to which place I hope you understand this logic okay now let's understand how to check multiple condition if using if statement okay and learn how to compare multiple variable so basically why we are using this so the basic the reason behind this we need this because we have to check each and every possible condition which can occur during this game and we also have to declare the winner or tie condition okay so basically their multiple condition is going to be happen here let me see okay just wait a minute so basically what is going to happen right now let me see you something so basically what is going to happen we have to check the multiple condition each time okay what are the possible condition which can make any user win okay so for example if x occupy this line then x is going to win okay if x occupy this line then x is going to win if x occupy this line then x is going to win if x occupy this line then he is going to win okay and same task is going to be we have to check this same task for oh also okay if occupy this line then oh is going to win over occupy this line then he has to win if occupy this diagonal then he has to win if occupy this line then he has to win so basically what you have to do we have multiple conditions to check during the execution of tic-tac-toe and we are going to check each time okay for each iteration after each and every push position if user check or user select then we have to what we have to do we have to check for each and every possible condition for that what we are going to use for that we are going to use if aleve statement okay so first of all let's learn how we are going to do what we can say find that these values are equal okay so how we are going to do this as you can see I have created a dictionary one okay now in this in this dictionary one what you are going to see here you can see the key seven key four and key one has what same value which is x okay and if you look at this key six and three it has same value which is zero zero or okay so keys three or and key six let me remove this one so okay now this is our dictionary okay now let's understand this concept then so basically what we are going to understand in this we are going to understand how we are going to see just wait a minute let me comment it okay so basically what we are going to see how we are use how we can check multiple condition in if statement okay so this is the best way to write if you have same values if all the variables have same values then you can write this either you can use then and logical operator or or logical operator but for this tic-tac-toe we doesn't require all those things okay so free so for this we just need what we just need here we are going to write this positions in dictionary zero one key seven in dictionary zero one key four and in dictionary zero one one key okay so we are going to just check if this all values are equal then what is going to be print then this line is going to be print let me execute this if we execute this code then you will find out that what is our output going to be that key seven four in one has same value okay why this is same values because this condition is going to return true why this going why this condition is going to return true let's see in dictionary that we already know that the seven four and one is holding our same value which is x okay now let's see something here what if if you have we have to check this type of diagonal let me comment it now let's understand see this what if we have to check this one like this diagonal okay what we are checking right now this one let me show you the conditions here conditions are dictionary zero one nine key sixth key and third key so you can imagine this is ninth key this is sixth key and this is third key so we are just comparing this okay so what we are comparing if this all values are equal then we are going to get this message and if these values are not equal then we are going to get this message okay so let's see what message we are going to get before that let's see what is our dictionary told us okay so you can easily see basically you can see the value of nine this key nine is holding the value empty space okay or white space okay and here the value or key six and key three is holding value oh right so when we execute this code this four line of code then we are going to get what then we are going to get something called basically what will happen this else part is going to be printed let's see let me execute this code when I execute this code I will get this key nine six three has different value okay I hope you understand about this what if I put if we put something like that if we put oh here then you can imagine what is going to be happen you can guess let me execute okay so at the time we are going to get this message what key nine six and three has same values you can see here key nine six and three has same values okay what if if I put zero here there instead of oh I put x then again we are going to get which message else part why because here dictionary at key nine this value is x and this value is o and this value is o so here we are going to get an false return and when this condition for written false we are going to or interpreter is going to execute this line okay now let's move to another one so what was that that part is okay so but we compare the key which one okay now let's let's check this condition okay we are talking about this condition how we are going to check this condition the same way we are just going to write dictionary one is dictionary one key eight dictionary equals to equals to dictionary one key five and equals to equals to dictionary one key two okay so this one is eighth position this one is fifth position and this one is second position right now for that what we are going if we look at our dictionary one what we can find you can see here in dictionary one you will find out that all these values eight five and two this keys eight five and two keys holding white spaces okay so if you find out if you run this equation you will what we are going to get let me run this if you run this can if a statement you are going to get this what you are just going to print this line that key eight five two has same value okay which looks good which looks key s this key eight key five and key two has same value but basically in this tic-tac-toe game what we are using we are using white space for holding empty spaces okay and why we are using white spaces let me explain you this thing so let's see here our where is our board okay let me see okay this is our board okay in our cell okay so this is our board okay what if if i don't mention here you can see to print me this kind of board i have to use white space if i remove these white spaces then what is going to happen this structure is going to be destroyed okay you can see here for this purpose what we are using we are using for empty space we are using white space for showing that this place is empty okay if you remove this all these spaces then what is going to happen the structure of this board is going to change this has become a different thing okay right so for that purpose we are using white spaces okay i hope you understand why we are using white spaces in this okay now so how to deal with this thing basically if you check this condition then this condition is going to say that all values are equal and if this all values are equal then he will maybe what will going to give us is going to say that this person is going to win okay but basically these all are empty places then how to deal with that so for how to deal with that we have to use this thing let me write this so basically what we are going to do let me comment it out so for that we are using this we are adding this condition into this condition so basically what we are doing is we are using this not equals to white space so basically what is going to happen here this line is going to first what this condition if we talk about this condition is going to check these values if these are equal then they are going to check if all values are equal to each other but they are they are not been equal to white space okay so if all these values are not equal to white space then what going to be happen then this values return this condition written true and then when this condition written true this line executed okay or what if this all values are not equal to or equal to white space when this value this thing happened then what will happen this condition will return false okay and when this condition written false this line is going to be executed okay so let me execute this code you will better understand this so let me see this okay we got something called just wait a minute now you can see here we get false key 8 key 5 and key 2 has white spaces okay why this is happening because we are using this condition here basically this condition is what is not equal to white spaces if they are not equal to white spaces then what is going to happen this line not going to happen for example let me change the dictionary again and then we will say it for example here we remove the white space and put 0 or o in place of this so I remove this white space and I put o in place of this okay and then if I execute this what is going to be happen you are going to get this message that 8 5 2 has same values right I hope you understand about this all okay now the last thing is okay so last thing let me write let me comment it out this okay so last thing what do we have to understand we have now to check how to check position 9 3 and 6 have same values but all values are not white space okay so how we are going to check just we are going to put something called this condition is which is what not equals to white space okay when you put this condition you will get this value okay I hope you understand this concept now let me explain you how to create a function so basically to create a function you just need to use def keyword and you have to mention a name of a basically a name of a function let's say if I create a function name game and we use parentheses to declare or define a function then we use colon and after an indentation we start writing the code of this basically what code or line of quotes we can say which belongs to this function for example let me print hello or we can write start start the game okay one thing is that this is just a definition okay so whenever you define a function and you can execute this code but but only when this function is going to execute when you call that function so if you call this function game then what is going to happen then this function is going to execute if you don't call this okay so basically how to execute function is just a way to that you have to mention the name of the function which you want to call okay using parentheses right so I hope you understand that how to define a function basically it's let me explain it again that we whenever we have to define a function we use def keyword then mention a name of the function and then use parentheses and then after colon we are going to write what whatever the body of going to be have go to a part of this function okay so basically if we talk about this function this function has a one line as a body of code which is start the game which is going to print start the game okay so whenever you call this function you are going to get this line that start the game okay and you can call a function many times multiple times you want as many times you want basically so if I write game and then game then you are going to get start game start the game start the game for two times what if I mention here something like this for i in range 10 colon so what is going to happen we are going to get this line we start the game start the game for 10 times okay so you can call any function any number of time you want okay so thank you for this lecture this lecture is going to be so tough to understand but if you have any doubt you can just rewind the video and see it again okay so in next video we are going to create that tic-tac-toe game okay so see you later till then take care thank you welcome back friends in this lecture we are going to discuss about how to create two players tic-tac-toe game in python so let's start so first of all we need to create a dictionary because in this dictionary we are going to use all the keys as the position or the location of that tic-tac-toe board game okay now initially all the values are basically empty spaces and after each move we are going to update this empty spaces with x or 0 now here comes after that we need to create a function which is going to help us to create what to create or show us this type of grid okay so for that we are going to create a function this function is going to help us okay to print every the board every time whenever we are going to use it after that we need to create a function which have all the game play functionality so let's define a function name game after that we need to create a variable turn variable and assign it x where we need because always tic-tac-toe game starts with x okay now let me create a variable count that is used in this variable to count the variable to count the number of moves of both players okay so initially we are going to put this count equals to 0 now create a follow for range function with argument 10 because we need to execute players turn for nine times so we are going to use for loop okay with range and in range we are going to give argument 10 now we are going to use function to print the board which we have created earlier okay now write a message to get a value from the user for that i'm going to write a message which tells tells the turns and ask for the value now after that we are going to use input method to get the input from the user now we need to use if statement to find the empty place on board and put input value move in it for that we are going to for that we are going to use this if statement if as a statement as we have discussed its functionality earlier in the course now what we have to do now we have to use alif if alif statement to check every possible win condition if player x or 0 has won for that we are going to use if as a alif statement and where we have given multiple condition to check each and every possible winning conditions which came across during the code execution and after that what we are going to do we are just going to check we are going to create if statement to check if either x or o win and for that what we are going to do basically we are going to create a if else statement okay if the count equals to equals to nine then what we are going to print game over and it's time now change the value of turn variable or the player after every move so for that we are using if else statement this logic we have already discussed in our last section last video now for calling this game function we are going to write the name of this game function and we are going to execute it so this is how we are going to create tic-tac-toe board or tic-tac-toe game i hope you understand about all the functionalities please recall everything and start playing it thank you and have a nice