Question: 1 turn = 0 remaining coins = 22 2 3 4 print(take turns removing 1, 2, or 3 coins) print(You win if you take the


1 turn = 0 remaining coins = 22 2 3 4 print("take turns removing 1, 2, or 3 coins") print("You win if you take the last coin.") 5 6 7 8 9 while remaining coins > : print(" There are", remaining coins, "coins remaining.") if turn%2 == : taken_coins = int(input("Player 1: How many coins do you take?")) else: taken_coins int(input("Player 2: How many coins do you take?")) 10 11 12 13 14 15 16 17 18 19 20 while taken_coins 3 or taken_coins > remaining_coins: print("That's not a legal move. Try again.") print(" There are", remaining_coins, "coins remaining.") if turn%2 == 0: taken_coins = int(input("Player 1: How many coins do you take?")) else: taken_coins = int(input("Player 2: How many coins do you take?")) 21 22 23 24 25 26 27 28 29 30 31 32 if remaining_coins - taken_coins print("No more coins left!") if turn%2 == 0: print("Player 1 wins!") print("Player 2 loses !") else: print("Player 2 wins!") print("Player 1 loses !") remaining_coins = remaining coins - taken_coins turn += 1 | Task 2: modify the program so that: Make the pool start with a random number ([20, 30] inclusive) of coins. Based on the number of the randomly generated coins at the beginning, let the computer determine whether Player 1 or Player 2 will be the winner based on the winning strategy (by printing out the winner). After deciding the supposed winner and loser, let the computer play out both of the roles. For the winner, the computer should be applying the winning strategy; for the loser, the computer should generate a random amount of coins while following all the rules of the game
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
