Part A and B important. The functions are just examples. A. Write a function called getDimension() that asks the user inputs for the dimensions that consists of two values: row and column, then return it to the mainline (also known as global scope) of the program. The range of the dimensions that the user can input is from 4 to 10 for both rows and columns Please refer to the gameplay sample. B. Next, use a 2-dimensional list to represent the game board, where each cell can be either empty (represented by a space " "), a token belonging to human (represented by "X"), or a token belonging to computer (represented by "O") as shown in Table 1. Write a function called printBoard(board) that takes a 2-dimensional list representing the game board and prints it to the console functions: 1) dropToken (board, col, token): takes a 2-dimensional list representing the game board, a column number, and a token (either "X" or "O") and returns the row number of the placed token. This function places the token at the specified location on the board. 2) isValidLocation(board, col): takes a 2-dimensional list representing the game board and a column number, and returns True if there is still space to place a token in that column (i.e., the top row of that column is empty), and False otherwise. 3) isTie(board): takes a 2-dimensional list representing the game board, and returns True if it is a tie game (i.e., all columns are full and no four in a row has been made), and False otherwise. 4) checkWinner(board, token): takes a 2-dimensional list representing the game board and a token (either "X" or "O") and returns True if the specified player has won the game, and False otherwise. Hint: this function needs to check four winning cases: horizontal, vertical, diagonal positive, and diagonal negative for the token placed ------------------------------------------------------------------------------------------------------------------------------------------ Question: Above is the instruction, assume part A the input of row and column are both 4. For part B how do I use variables "row" and "column" from part A "return row, column" in "def getDimension()". Also from part B, the parameter of the function, printBoard(board). What is it indicating and what is the purpose of the parameter "board" in all the functions above? THX!
*Part A and B important. The functions are just examples.
A. Write a function called getDimension() that asks the user inputs for the dimensions that consists of two
values: row and column, then return it to the mainline (also known as global scope) of the program. The
range of the dimensions that the user can input is from 4 to 10 for both rows and columns Please refer
to the gameplay sample.
B. Next, use a 2-dimensional list to represent the game board, where each cell can be either empty
(represented by a space " "), a token belonging to human (represented by "X"), or a token belonging to
computer (represented by "O") as shown in Table 1. Write a function called printBoard(board) that
takes a 2-dimensional list representing the game board and prints it to the console
functions:
1) dropToken (board, col, token): takes a 2-dimensional list representing the game board, a
column number, and a token (either "X" or "O") and returns the row number of the placed token.
This function places the token at the specified location on the board.
2) isValidLocation(board, col): takes a 2-dimensional list representing the game board and a
column number, and returns True if there is still space to place a token in that column (i.e., the
top row of that column is empty), and False otherwise.
3) isTie(board): takes a 2-dimensional list representing the game board, and returns True if it is a tie
game (i.e., all columns are full and no four in a row has been made), and False otherwise.
4) checkWinner(board, token): takes a 2-dimensional list representing the game board and a token
(either "X" or "O") and returns True if the specified player has won the game, and False
otherwise. Hint: this function needs to check four winning cases: horizontal, vertical, diagonal
positive, and diagonal negative for the token placed
------------------------------------------------------------------------------------------------------------------------------------------
Question:
Above is the instruction, assume part A the input of row and column are both 4. For part B how do I use variables "row" and "column" from part A "return row, column" in "def getDimension()".
Also from part B, the parameter of the function, printBoard(board). What is it indicating and what is the purpose of the parameter "board" in all the functions above?
THX!
![HNM anno
1
2
3
4
5
6
7
8
9
10
1234516718192021222B24252627
def getDimension ():
global row
global column
row = 4
column = 4
return row, column
getDimension ()
def printBoard (board):
board = [[
]]
for i in range (row-1):
board [0].append(' ')
board = board*column
for 1s in board:
print("/")
for item in ls :
if item ==
print ("/", end="" )
else:
print (" + item +
print("\n", end="")
printBoard (1)
11 11
end="" )](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F4c988bbe-f4a7-4476-ac3e-14c02c9d633c%2Fddb7c0d6-0e13-46ae-bc92-a9648ec92a16%2Fw9v5ir_processed.png&w=3840&q=75)

Step by step
Solved in 4 steps with 9 images









