Question: Plese us single variable loops(for and while) to solve this question. Don't use abstract list function and recursion.The programming language is Python.do this without the

Plese us single variable loops(for and while) to solve this question. Don'tuse abstract list function and recursion.The programming language is Python.do this withoutPlese us single variable loops(for and while) to solve this question. Don't use abstract list function and recursion.The programming language is Python.do this without the following: continue, break, enumerate and {}. as none of those are allowed, thanks.

This question is inspired by the game Battleship. The details and rules are not relevant here. However, if you are unfamiliar with the game and interested, you can see Wikipedia to learn about it. If you are familiar with the game, then don't try to use your knowledge of its rules and set-up to try and impose any unstated restrictions or assumptions on this problem. Write the function battleship (deployments) that consumes a nested list deployments and returns a natural number corresponding to the number of valid guesses made. The consumed list is a list of lists of integers. The five inner lists provide the positions on the gameboard for each ship type (carrier, battleship, destroyer, submarine, and patrol boat). See the detailed description below, but these inner lists will be of the following lengths: 5, 4, 3, 3, 2. Each integer in the inner lists is the number of a cell in a 10 by 10 grid where cells are numbered as shown below: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 Your function should behave as follows: Read input from the keyboard with the prompt: Enter a guess: Checks for valid input (a number between 1 and 100). If the input is not valid, your function will output: You must enter a number between 1 and 100!. It will then re-prompt the user to enter a guess. If the input is a 'miss' meaning it missed all of the ships, your function will output: Miss!. It will then re-prompt the user to enter a guess. If the input is a 'hit' meaning it hit one of the ships, your function will output: Hit!. If not all ships have been sunk, it will re-prompt the user to enter a guess. If all ships have been sunk, then it will output: Game Over!. Then it will output the game board as described below. If the input was already guessed, report Hit! or Miss! as above as though the user had not already guessed the value already. When printing the gameboard, the character for a cell must be: the string "C" to represent the carrier, which spans 5 cells on the game grid the string "B" to represent the battleship, which spans 4 cells on the game grid the string "D" to represent the destroyer, which spans 3 cells on the game grid the string "S" to represent the submarine, which spans 3 cells on the game grid the string "P" to represent the patrol boat, which spans 2 cells on the game grid a "." (period) otherwise. Print a single space between characters on a line but do not print a space character at the end of the line. That is, each line must include exactly 9 space characters and 10 characters that are ".", "C", "B", "D", "S", or "P". You can assume that the nested list will always contain the deployments in the above order and that the ships will not overlap at all on the gameboard. In other words, each number will have only one ship on it. The printed gameboard should look like the following for battleship ([[96, 97, 98, 99, 100], [42, 52, 62, 72], [10, 20, 30], [55, 56, 57], [26, 27]]) would be: D D D PP . B.. SSS B CCCC

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 Databases Questions!