w it works: • First, it is randomly determined if the user starts the game or the computer and this information is shown to the user. The player who starts always starts as “X”. • The players (computer and the user) will then take turns in playing. The computer will choose a random empty spot on its turn. The user enters its choice in the console. • Each of the empty spots have a corresponding number that the players choose on their turn. If the user enters anything other than the number of an empty spot (not yet filled with “X” or “O”), it will not be accepted, and they will be prompted to enter a correct number.

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter8: Arrays
Section: Chapter Questions
Problem 7RQ: If the intNums array contains six elements, which of the following statements assigns the number 6...
icon
Related questions
Question

this code should be in python:

you will be implementing a simple Tic-Tac-Toe game without the graphics.
Here is how it works:

• First, it is randomly determined if the user starts the game or the computer and this
information is shown to the user. The player who starts always starts as “X”.
• The players (computer and the user) will then take turns in playing. The computer will
choose a random empty spot on its turn. The user enters its choice in the console.
• Each of the empty spots have a corresponding number that the players choose on their
turn. If the user enters anything other than the number of an empty spot (not yet filled
with “X” or “O”), it will not be accepted, and they will be prompted to enter a correct
number.                                                                                                                                                                          • After each turn, two things need to be done: 1) displaying the updated board 2) checking
if anyone has won (it should be printed who has won – the user or the computer).
• The game goes on until someone wins or until all the 9 empty spots are filled and no one
has won. When the game ends, the user should see the message saying who has won
(even if no one) 

You should implement at least the two following functions:


displayBoard(board)
Parameter board is a dictionary containing the non-empty spots of the board.
This function does not return anything. It will just print the content of the
board as depicted in Gameplay example.


hasWon(board)
Parameter board is a dictionary containing the non-empty spots of the board.
This function determines if anyone has won and returns a suitable value (up to
you how you want to handle the returned value). 

Creating other functions can be helpful (such as checking if the user input is valid, the general
gameplay, etc.). The design and implementation of other functions is up to you.

Game is starting.
You will start the game. Please enter your choice:
4
Updated board:
_x_],
Computer is playing.
Updated board:
|_0_
_x_|
Transcribed Image Text:Game is starting. You will start the game. Please enter your choice: 4 Updated board: _x_], Computer is playing. Updated board: |_0_ _x_|
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 8 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT