Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete the following function copyStoG( G, S) so that the following program would produce the correct output as shown below. Please enter only the

Please complete the following function copyStoG( G, S) so that the following program would produce the correct output as shown below. Please enter only the code for copyStoG( G, S) function as your answer to this problem.

# Python program

def show( G ): # show the 3X3 game board G

for r in range(0, 2+1): # r: 0,1,2

for c in range(0, 2+1): # c: 0,1,2

print( G[r][c],end="" ) # same line

print( ) # end of show ( G ) # end this line

def copyStoG( G, S ): # G is 3x3 board, S is string of 9 characters

# copy 9 chars from string S into G of 3x3 board

i = 0 # string index 0,1, ... ,8

# ENTER YOUR CODE HERE for this function - - - - - - - - - - -

# Warning: If you copy your code from Visual Studio IDE into here, those

# indentations will be lost. You must put those indentations back, otherwise

# your code would have severe syntax errors.

# - - - - - - - - - - - - - - -

# end of createG( G, S)

# MAIN PROGRAM:You must not change any of the following code.

O = 'O'

X = 'X'

G = [ [X,X,X], [X,X,X], [X,X,X] ] # G is a game board of 3x3 array or list

S1 = "XXXXXXXXX"

S2 = "OOOOOOOOO"

S3 = "OXOOXOXOX"

S4 = "XXOOOXXOX"

copyStoG( G, S1) # copy S (a string of 9 characters) into G board of 3x3

print("Game board for S1 \"" + S1 + "\" is as follows:")

show( G ) # print G game board of 3x3

copyStoG( G, S2) #

print("Game board for S2 \"" + S2 + "\" is as follows:")

show( G ) # print G game board of 3x3

copyStoG( G, S3) #

print("Game board for S3 \"" + S3 + "\" is as follows:")

show( G ) # print G game board of 3x3

copyStoG( G, S4) #

print("Game board for S4 \"" + S4 + "\" is as follows:")

show( G ) # print G game board of 3x3

# End of MAIN PROGRAM =====================.

The output of the above program (when completed properly) should be as follows:

Game board for S1 "XXXXXXXXX" is as follows:

XXX

XXX

XXX

Game board for S2 "OOOOOOOOO" is as follows:

OOO

OOO

OOO

Game board for S3 "OXOOXOXOX" is as follows:

OXO

OXO

XOX

Game board for S4 "XXOOOXXOX" is as follows:

XXO

OOX

XOX

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions

Question

What is a niche market?

Answered: 1 week ago

Question

1. How is the newspaper help to our daily life?

Answered: 1 week ago

Question

1. Prepare a short profile of Mikhail Zoshchenko ?

Answered: 1 week ago

Question

What is psychology disorder?

Answered: 1 week ago