Professional Documents
Culture Documents
Python Microproject
Python Microproject
Python Microproject
Subject
Guided by
Prof. P.H.Gutte
This is to certify that this Micro-Project contains the bonafied work of
following students of Sixth Semester Diploma in Computer
Engineering, of Government Polytechnic, Hingoli for the session 2022-
23. They have completed their Capstone project Planning entitled
" Tic Tac Toe” under the guidance of Prof.P.H.Gutte. This Project
report is being submitted to MSBTE, Mumbai, in the partial fulfillment
for the Diploma in computer Engineering
Rol
Sr. Enrollmen Exam
l Name of the Student
No. t No. Seat No.
No.
1 3144 2011630094 448329 Sakhare Munja Arjun
2 3115 2011630017 448292 Bade Keshav Santosh
3 3114 2011630016 448291 Swami Shivprasad Buddivant
crown All efforts with success. We are be grateful to our project guide
Prof. P.H. Gutte for the guidance, inspiration and Constructive suggestions
that helpful us in the preparation of This project. Our me to this project and
express our sincere thanks to her for constant encouragement. express our
throughout this project Last but not the least; we extend my sincere thanks
to Our family members and our friends for their constant support
Tom Gutschmidt This book covers game We used this book to learn
how to
(Premier Press) programming in three build efficient, flexible and
different well-
scripting languages i.e, integrated programs and
Python, Lua and Ruby systems
5.Program
def print_board(board):
"""
This function prints out the current state of the board.
"""
print(" | | ")
print(" "+board[0]+" | "+board[1]+" | "+board[2]+" ")
print("___|___|___")
print(" | | ")
print(" "+board[3]+" | "+board[4]+" | "+board[5]+" ")
print("___|___|___")
print(" | | ")
print(" "+board[6]+" | "+board[7]+" | "+board[8]+" ")
print(" | | ")
def check_win(board):
"""
This function checks if a player has won.
"""
win_combinations = [(0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7), (2, 5, 8), (0,
4, 8), (2, 4, 6)]
for comb in win_combinations:
if board[comb[0]] == board[comb[1]] == board[comb[2]] != " ":
return board[comb[0]]
return False
def check_tie(board):
"""
This function checks if the game is a tie.
"""
for i in board:
if i == " ":
return False
return True
def play_game():
"""
This function plays a game of Tic Tac Toe.
"""
print("Welcome to Tic Tac Toe!")
board = [" "]*9
players = ["X", "O"]
current_player = 0
while True:
print_board(board)
move = get_move(players[current_player], board)
board[move] = players[current_player]
winner = check_win(board)
if winner:
print_board(board)
print(f"Player {players.index(winner)+1} ({winner}) wins!")
break
elif check_tie(board):
print_board(board)
print("Tie game!")
break
current_player = (current_player+1)%2
play_game()
6.Output
1)
2)
3)
4)
5)
6)
7)
8)
8.0 Skill Developed/ learning out of this Micro-Project
We learnt,
1. To demonstrate the use of Operators.
2. To perform operations on data structures in Python.
3. To develop functions for given problems.
4. Efficient communication skills.
5. Working as a team member for developing c program.
6. Developing leadership qualities.
Subject Teacher
Prof.P.H.Gutte