Inspiration of the project.
python is a very powerful programming language and after learning the basics and several aspects of the python there is a feeling to building something from the knowledge and the best way to start is with building some sort of game before we could jump upon the gui part of python for which it is known.
The best game that could come in mind which doesn’t need the use gui is the TIC TAC TOE this game also test the mathematical knowledge during the creation. so lets begin building it

thing to know before starting coding
- How to use functions in python
- knowledge of control structure
- list datatype in python
coding in python idle
so now with this much knowledge lets start with coding
first of all we need a board on which we play game so lets create the board
we will create a list which will have 9 spaces and as we haven’t started the game we will put dashes in the game board.

thus the game board is created. now we will need some function which we will create and will help us to provide the functionality to the game i.e now which player will play and is game over or who has won the game or it is a draw
so for that we will create four function that are:-
- handle_turn()
- flip_player()
- check_if_game_over()
- check_for_winner()
- check_for_tie()
- Handle_Turn
so we need to tell in the code that whose playing now and after this player finishes by playing a valid move we need to flip the players so that the other player can start its turn.so in this function we will check that the move made is valid or not and if the move is not valid we will inform the player to play the valid move

So by this we completed our handle_player function. As we can see that we take a entry from the user i.e the value from 1-9 on the board and check the entry if it is in the range from 1-9 and if not we raise an error also we can see that the value of position is decremented by 1 as list has the first element starting from 0.
- Flip_Player
When one player finishes its turn we have to switch the player to and take entry from him/her. so how do we distinguish between them? If “X” finishes its turn then we need to switch to “0” and if “0”has completed then switch to “x”. we will perform the same operation as we discusss

Here we can see that if the current player playing is “X” we flip the player to “0” by changing the value of the current_player and if the other is the case we flip to “x”so we completed with player flipping.
3. Check_If_Game_Over
We handled the turns, flip the player after the completion of the it’s turn so now what we should do? the answer is we will check if any player has won the game or not. So when we can say game is over, when all the places in the board is completed or not or any win combination for”X” or “0” is made otherwise it is a tie

we create two function for win as well as for tie. the main reason we perform everything inside the function is that it makes debugging easier also if makes easy for other programmer to review the code
4. Check_ For_Winner

We can observe in the picture that any one i.e “X” or “0” can win the game only if it can get 3 consecutive “X” or “0” in either the row or column or diagonally. here we have 3 Rows, 3Column and 2 Diagonals where the win situation can be created so if we come across any of this situation in the game in between the game or at the end we can declare the one with consecutive “X” is winner or the wise versa.


From left we can see the code for checking winner which include row checking, column checking and the diagonals checking here we have consider the board numbering i.e the list numbering to give the position that make 3 consecutive places that make up the win. The positioning has been explained in the the same above in fig;1
5. Check_For_Tie
Now the last thing we need to check which will complete our Game is if we have come across any tie or not which we will check when no position in the Board is left empty

So we will check that is any blank left or now? if yes then game still going on and if no then we have to check for win and if we didn’t get any win then we have come across tie.This is the last thing and we completed our game

The game is build using the python which can play with our friend and enjoy
Code for the this project(Game)
Copy the code and paste in the python Shell or any other other python toolkit you use like Pycharm