PYTON PROGRAM IN PYTHON 3.3: Your program should work as follows: 1. Ask the use
ID: 3767772 • Letter: P
Question
PYTON PROGRAM IN PYTHON 3.3:
Your program should work as follows:
1. Ask the user for the name of a file that contains the board
2. Read in and store the board in a 2D list
3. Ask the user for a coordinate to start auto-filling from
-They may also choose to quit at this point
4. Ask the user for a symbol to auto-fill with
5. Ask the user if they would like to see a step-by-step of the auto-fill
6. Auto-fill the board starting at that point, using their chosen character
-This function must be recursive, and must make recursive calls to neighboring cells in the following order:
1. The cell above the current one
2. The cell to the right of the current one
3. The cell below the current one
4. The cell to the left of the current one
-If you don’t follow this order, your output won’t match ours
7. Print out the resulting board (and the step-by-step, if requested)
8. Allow the user to choose a new coordinate (or to quit)
You will need to validate the following things:
Getting the filename
o The filename must end in “.dat” or “.txt”
Getting the cells to start auto-filling from
o We guarantee the user will enter either
The character “Q”
Two integers, separated by a comma (e.g., 5,6 or -1,99 or 0,0 etc.)
o The row (the first number) must be
A valid index for the number of rows your board has (i.e., it starts at index 0, and goes up to index row_size – 1)
o The column (the second number) must be
A valid index for the number of columns your board has (i.e., it starts at index 0, and goes up to index column_size – 1)
o You must check both row and column
Getting the symbol to use in the auto-fill
o The symbol must be a single character
Getting the choice for step-by-step
o The user’s answer must be either “yes” or “no” in all lowercase
Explanation / Answer
m = int(input('number of rows, m = ')) n = int(input('number of columns, n = ')) matrix = []; columns = [] # initialize the number of rows for i in range(0,m): matrix += [0] # initialize the number of columns for j in range (0,n): columns += [0] # initialize the matrix for i in range (0,m): matrix[i] = columns for i in range (0,m): for j in range (0,n): print ('entry in row: ',i+1,' column: ',j+1) matrix[i][j] = int(input()) print (matrix)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.