Question: NOTE : Is learning Python programming (currently on chapter 5) with the following textbook: Book Starting Out With Python 3rd Edition by Gaddis

NOTE: Is learning "Python programming" (currently on chapter 5) with the following textbook:

Book "Starting Out With Python" 3rd Edition by Gaddis

 NOTE: Is learning "Python programming" (currently on chapter 5) with the

following textbook: Book "Starting Out With Python" 3rd Edition by Gaddis 2.

2. Write a program that lets the user play the game of Cockroach, Foot, Nuclear Bomb against the computer. The program should work as follows When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen cockroach. If the number is 2, then the computer has chosen foot. If the number is 3, then the computer has chosen nuclear bomb. (Don't display the computer's choice yet.) The user enters his or her choice of "cockroach", "foot", or "nuclear bomb" at the keyboard. The computer's choice is displayed. A winner is selected according to the following rules - If one player chooses cockroach and the other player chooses nuclear bomb then cockroach wins. (The cockroach outlives the nuclear bomb.) If one player chooses nuclear bomb and the other player chooses toot, then nuclear bomb wins. (Nuclear Bomb blows up foot.) A131 Programming Assignment If one player chooses foot and the other player chooses cockroach, then foot wins. (Foot squashes cockroach.) - If both players make the same choice, it's a tie and neither player wins. If the player won, print You win!. If the computer wins, print Computer wins! If it's a tie, print It's a tie! You must implement the following functions get computer_move: Takes no parameters. Randomly generates an int in the range [1, 3 and returns that number get winner: Takes two ints that represent move options. 1 is Cockroach; 2 is Foot; 3 is Nuclear Bomb. Returns 1 if the first player (the first parameter) won Returns 2 if the second player (the second parameter) won. Returns 3 if there is a tie. o get player move: Takes no parameters. Asks the user for their move (foot cockroach, or nuclear bomb) until the user enters a valid move. Returns the int corresponding to the move choice. Hence, it would return 1 if the player chose cockroach, 2 if the player chose foot, and 3 if the player chose nuclear bomb

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!