94.2k views
5 votes
Functions can be used to replace multiple code statements that perform essentially the same task with different values. this occurs in the tic-tac-toe game program within the tutorial. see the printboard function created there as an example. if using a function to implement the players selecting a column and row portion of the tic-tac-toe program, what input arguments would it need in its definition?

a.) whether selecting a column or row, and the player; for example, def turn(col or row, player):
b.) the player; for example, def turn(player):
c.) the board position; for example, def(col, row):
d.) whether selecting a column or row; for example, def turn(col or row):

User Dottedquad
by
8.0k points

1 Answer

5 votes

Final answer:

c.) the board position; for example, def(col, row):In a tic-tac-toe program, the function to select a column and row would need the board position as input arguments, defined as def turn(col, row),

Step-by-step explanation:

When implementing a function to facilitate players selecting a column and row in a tic-tac-toe program, the function would most likely need the board position as input arguments. This would be option C: the board position; for example, def turn(col, row).

The reasoning for this choice is that each player's turn in tic-tac-toe involves choosing a specific column and row on the board to place their mark (either 'X' or 'O'). The function would also implicitly or explicitly need to know which player is taking the turn to update the board accordingly.

However, since the function specifically asks for ‘selecting a column and row,’ the essential arguments are col (column) and row (row) indicating the desired cell on the tic-tac-toe board where the player intends to make their move.

User Andrew Svetlov
by
7.8k points