Question: Functions can be used to replace multiple code statements that perform essentially the same task with different values. This occurs in the Tic - Tac
Functions can be used to replace multiple code statements that perform essentially the same task with different values. This occurs in the TicTacToe game program within the tutorial. See the printBoard function created there as an example. What other code within the TicTacToe program would be a good set of statements to turn into a function?
a
Changing validMove from False to True:
validMoveTrue;
b
Decrementing the column and row:
col
row
c
Players selecting a column and row:
while col or col :
col intinputplayerTurn player, select a column :
if col or col :
printThe column must be between and
while row or row :
row intinputplayerTurn player, select a row :
if row or row :
printThe row must be between and
d
Changing playerTurn from X to O:
if playerTurn X:
playerTurnO
else:
playerTurnX
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
