Question: Replace all the '???' To the appropriate coding. There's a second part of this assignment I am going to upload it in a different question

Replace all the '???' To the appropriate coding. There's a second part of this assignment I am going to upload it in a different question since I can't upload two picture at once.  


# CIS226 - Midterm Exam Tic Tac / Toe # Name: Paola

# CIS226 - Midterm Exam - Tic / Tac / Toe # Name: Paola Jimenez - REPLACE THIS WITH YOUR NAME (1 Point) # Points: 19 plus 1 for the change of the file name to use your name = 20 points. # 1. Replace the ??? with the appropriate statement to load the random module: (1 Point) ??? random # 2. Replace the ??? with the appropriate multiplier (*) expression to have locations assigned the list ['', ' ''] where there are nine (9) elements with ' # assigned. (1 Point) locations= [' ']??? # 3. Replace each ??? with the appropriate dictionary code to assign the keys 'User', 'Computer' , and 'Tie' to an initial value of zero (0). (3 Points) scores={???, ???, ???} COL_WIDTH=3 ROW_WIDTH=3 def inputLocation ( locations) : # 4. Replace the ??? to assign the flag to be a true boolean value. (1 Point) flag=??? print ("The current board: ") for row in range (0, ROW_WIDTH) : for col in range (1, COL_WIDTH+1) : # 5. Replace each ??? with parts of an expression to calculate the value for loc as three (3) times the row, plus the column value (col). (2 Points) loc=???*???+??? if ( locations [loc-1]==' ') : print ("|", row*3+col, sep=' ', end=' ' ) else: print ("|", locations [loc-1], sep=' ', end=' ') print (" [") while flag: loc=int (input ("Select a numeric location: ")) if locations [loc-1]==' locations [loc-1]='X' flag=False else: print ("Error. Location", loc, "is not available.") return loc def printBoard ( locations) : for row in range (0, ROW_WIDTH) : for col in range (1, COL_WIDTH+1) : val=row*3+col print ("|", locations [val-1], sep=' ', end=' ' ) print (" ") return def compute0 ( locations ) : flag=True while flag: loc=random. randint (1, len( locations) ) # 6. Replace each ??? to test to ensure that the location is blank. (1 Point) if locations [loc-1] ??? ???: locations [loc-1]='0' flag=False printBoard ( locations) return loc def checkWinner ( values) : flag = values [0] != ' and values [0]==values [4] and values [4]= =values [8] flag = flag or (values [2] != ' ' and values [2]==values [4] and values [4]==values [6]) if not flag: for i in range (0, COL_WIDTH) : flag = flag or (values [i] != ' ' and values [i]==values [i+3] and values [i+3]==values [i+6] ) if not flag: # 7. Replace each of the ??? in order to complete the logic using a for loop to detect of matching # rows that are not spaces. (3 points) for r in range(0 , ROW_WIDTH)

# CIS226 - Midterm Exam Tic Tac / Toe # Name: Paola Jimenez REPLACE THIS WITH YOUR NAME (1 Point) # Points: 19 plus 1 for the change of the file name to use your name 20 points. # 1. Replace the ??? with the appropriate statement to load the random module: (1 Point) ??? random # 2. Replace the ??? with the appropriate multiplier (*) expression to have locations assigned the list ['' ,' 'l where there are nine (9) elements with I 1 # # assigned. (1 Point). locations=[]??? # 3. Replace each ??? with the appropriate dictionary code to assign the keys 'User', # 'Computer', and 'Tie' to an initial value of zero (0). (3 Points) scores={???, ???, ???} COL WIDTH=3 ROW_WIDTH=3 def inputLocation (locations): # 4. Replace the ??? to assign the flag to be a true boolean value. (1 Point) flag=??? print("The current board: ") for row in range(0, ROW_WIDTH): for col in range (1, COL_WIDTH+1): # # 5. Replace each ??? with parts of an expression to calculate the value for loc as three (3) times the row, plus the column value (col). (2 Points) loc=???*???+??? if (locations [loc-1] ==' '): print("|") while flag: else: loc= int(input ("Select a numeric location: ")) if locations [loc-1] ==' ': locations [loc-1] ='X' flag-False print("Error. Location", loc, "is not available.") else: return loc print("", row*3+col, sep='', end='') print("", locations [loc-1], sep='', end='') def printBoard (locations): return for row in range(0, ROW_WIDTH): for col in range (1, COL_WIDTH+1): val=row*3+col print("", locations [val-11, sep=' ', end='') print("|") = def compute0 (locations): flag-=True while flag: - loc=random. randint (1, len(locations)) # 6. Replace each ??? to test to ensure that the location is blank. (1 Point) if locations [loc-1] ??? ???: locations [loc-1]='0' flag=False printBoard (locations) return loc def checkWinner (values): flag = values [0] != and values [0] ==values [4] and values [4] ==values [8] flag flag or (values [2] != and if not flag: for i in range(0, COL_WIDTH): flag flag or (values [i] != and values [i] ==values [i+3] and values [i+3] ==values [i+6]) = if not flag: # 7. Replace each of the ??? in order to complete the logic using a for loop to detect of matching # rows that are not spaces. (3 points) for r in range(0, ROW_WIDTH): values [2] ==values [4] and values [4] ==values [6]) 476 031

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!