Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Step 1 - Fill out the FunctionListingSonar.txt. Remember - do not just let me kn

ID: 3819698 • Letter: S

Question

Step 1 - Fill out the FunctionListingSonar.txt. Remember - do not just let me know the names of the return value or the parameters. DESCRIBE these by explaining the content and giving the data type!!!

Step 2 - As you discovered, the display is NOT wonderful. Copy the program into a file called sonar2.py. Then, change from...

To something more readable:

Firstly, this is the txt. file.

And let me show you the code.

Explanation / Answer

import random import sys def drawBoard(board): #print("What is the board in drawBoard?", board) #find content #print(type(board)) # Draw the board data structure. hline = ' ' # initial space for the numbers down the left side of the board for i in range(1, 6): hline += (' ' * 9) + str(i) # print the numbers across the top print(hline) print(' ' + ('0123456789' * 6)) print() # print each of the 15 rows for i in range(15): # single-digit numbers need to be padded with an extra space if i < 10: extraSpace = ' ' else: extraSpace = '' print('%s%s %s %s' % (extraSpace, i, getRow(board, i), i)) # print the numbers across the bottom print() print(' ' + ('0123456789' * 6)) print(hline) def getRow(board, row): # Return a string from the board data structure at a certain row. boardRow = '' for i in range(60): boardRow += board[i][row] return boardRow def getNewBoard(): # Create a new 60x15 board data structure. board = [] for x in range(60): # the main list is a list of 60 lists board.append([]) for y in range(15): # each list in the main list has 15 single-character strings # use different characters for the ocean to make it more readable. if random.randint(0, 1) == 0: board[x].append('~') else: board[x].append('`') return board def getRandomChests(numChests): # Create a list of chest data structures (two-item lists of x, y int coordinates) chests = [] for i in range(numChests): chests.append([random.randint(0, 59), random.randint(0, 14)]) return chests def isValidMove(x, y): # Return True if the coordinates are on the board, otherwise False. return x >= 0 and x = 0 and y abs(cy - y): distance = abs(cx - x) else: distance = abs(cy - y) if distance
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote