Computer 3
Computer 3
SCHOOL
PYTHON
The purpose of this project is to implement the rules and logic of Tic
Tac Toe using Python. It involves the use of core programming concepts
such as:
Thank you all for making this journey both enriching and memorable.
INDEX
1. ACKNOWLEGMENT
2. INTRODUCTION
3. SALIENT FEATURES
4. SYSTEM REQUIREMENTS
5. FLOW CHART
6. SOURCE CODE
7. OUTPUT
8. BIBLIOGRAPHY
SALIENT FEATURES
EXTENSIVE LIBRARIES
SYSTEM REQUREMENTS
Main processor : Pentium 111 and above.
Hard disk : 1 GB
RAM : 1GB
Language : Python.
FLOWCHART
START
ASK FOR
PLAYER’S
PLAYER’S COMPUTER’S
MOVE MOVE
Get’s its turn Check if
Show the board computer
SOURCE CODE won
Get’s computer turn
Gets players
move Ask to play again
Check for
tie
# Initialize the game board as a list of 9 empty spaces
# Player symbols
print("\n")
print(" | | ")
print(f" 1 | 2 | 3 ")
print("___|___|___")
print(" | | ")
print(f" 4 | 5 | 6 ")
print("___|___|___")
print(" | | ")
print(f" 7 | 8 | 9 ")
print(" | | ")
print("\n")
# Game loop
current_player = 1
game_running = True
while game_running:
# Display the updated board
print("\n")
print(" | | ")
print("___|___|___")
print(" | | ")
print("___|___|___")
print(" | | ")
print(" | | ")
print("\n")
# Get the player's move
valid_move = False
try:
board[move] = player_marks[current_player]
valid_move = True
else:
except ValueError:
print("Please enter a valid number between 1 and 9.")
winning_combinations = [
]
for combo in winning_combinations:
if board[combo[0]] == board[combo[1]] ==
board[combo[2]] == player_marks[current_player]:
print(f"Player {current_player}
({player_marks[current_player]}) wins!")
game_running = False
break
print("It's a draw!")
game_running = False
# Switch players
print("\nFinal Board:")
print("\n")
print(" | | ")
print("___|___|___")
print(" | | ")
print("___|___|___")
print(" | | ")
print(f" {board[6]} | {board[7]} | {board[8]} ")
print(" | | ")
print("\n")
2.www.github.com
3.Slideshare
5.Chat-Gpt