Registrations Closing Soon for DevOps Certification Training by CloudxLab | Registrations Closing in

  Enroll Now

Tic Tac Toe with Python - Define the Constants

In this step we will define the constants that we would be using throughout this program. These are called Global Constants in Python since as we are declaring them outside any function.

How to define a constant in Python? You can define a constant in Python as shown below:

SOME_CONSTANT = [...]

These constants can be accessed from other file too! If the file name where these constants are declared is firstfile.py, then you can access to it from other files using the following code (assuming they are in the same directory):

import firstfile
print firstfile.SOME_CONSTANT

In our program, we would define a total of 5 constants, let's start coding!

INSTRUCTIONS
  • Simply copy paste the entire code:

    X = "X"
    O = "O"
    EMPTY = " "
    TIE = "TIE"
    NUM_SQUARES = 9
    

    Here, X and O marks the symbols we would use to play the game of Tic Tac Toe. EMPTY defines an empty variable. TIE variable is there to check if the match is a draw. Finally, NUM_SQUARES defines the total number of squares in a game of Tic Tac Toe.


No hints are availble for this assesment

Answer is not availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...