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!

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

*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="" )
Transcribed Image Text: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="" )
Expert Solution
steps

Step by step

Solved in 4 steps with 9 images

Blurred answer
Knowledge Booster
Linked List Representation
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education