1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GuDViN [60]
3 years ago
14

Modify the following code so that:

Computers and Technology
1 answer:
Verizon [17]3 years ago
4 0

Answer:

Explanation:

The following code makes all the necessary changes so that the game runs as requested in the question. The only change that was not made was making the number of coins random since that contradicts the first rule of the game that states that the game starts with 22 coins.

turn = 0

remaining_coins = 22

print("Take turns removing 1, 2, or 3 coins. ")

print("You win if you take the last coin.")

while remaining_coins > 0:

   print("\nThere are", remaining_coins, "coins remaining.")

   if turn % 2 == 0:

       # Player1

       taken_coins = int(input("Player 1: How many coins do you take?"))

       turn += 1

   else:

       # Player2

       taken_coins = int(input("Player 2: How many coins do you take?"))

       turn += 1

   if taken_coins < 1 or taken_coins > 3 or taken_coins > remaining_coins:

       print("That's not a legal move. Try again. ")

       print("\nThere are", remaining_coins, "coins remaining.")

       if turn % 2 == 0:

           # Player1

           taken_coins = int(input("Player 1: How many coins do you take? "))

           turn += 1

       else:

           # Player2

           taken_coins = int(input("Player 2: How many coins do you take? "))

           turn += 1

       remaining_coins -= taken_coins

   else:

       remaining_coins -= taken_coins

   if remaining_coins - taken_coins == 0:

       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

   else:

       continue

You might be interested in
Alice is an investor who has created a device controlled by an app that will water plants automatically. Alice has no experience
oksian1 [2.3K]

Answer:

3rd one

Explanation:

took test

5 0
3 years ago
___________ is an unsecured client server application / protocol that transfers files between two computers.
Alexus [3.1K]
It is known as the File Transfer Protocol or FTP. It is based on a customer server demonstrate design and uses isolate control and information associations between the customer and the server. FTP clients may conform themselves with an unmistakable content sign-in convention, regularly as a username and secret word, yet can interface namelessly if the server is designed to permit it.
6 0
4 years ago
What is an algorithm? An executable file that has been converted into machine language A set of markup instructions A set of ins
mario62 [17]

Answer:

A set of instructions to meet a requirement of some kind

Explanation:

An algorithm is a set of instructions to meet a requirement of some kind, not all the algorithm are for computers, we can form an algorithm of how to make a cake.

5 0
3 years ago
Explain chart elements​
taurus [48]

Answer:

The different parts that make up a chart are referred to as chart elements.

Most of the items on a chart can be repositioned by clicking on an item and dragging it with the right mouse button.

The black handles also indicate that the item could be moved, resized and formatted.

All of these chart items (except the chart area) once selected can be moved around and resized relative to other items.

Explanation:

4 0
3 years ago
Susan is creating a spreadsheet, and she needs to enter the months of the year in column A. Susan should _____.
AysviL [449]
Enter January in A1 hold mouse in bottom right hand corner of cell. Hold mouse button down and drag the mouse. Excel will populate the months of the year
3 0
3 years ago
Read 2 more answers
Other questions:
  • How can you recognize an unsecured wireless network?
    9·1 answer
  • How do Hlookup and Vlookup differ?
    5·2 answers
  • Why did the creation of ARPANET help with this critical need?
    9·1 answer
  • Which of the following is not the name of an air mass?
    7·1 answer
  • Why are modern manufacturing techniques preferred over those historically used by artisans?
    13·1 answer
  • How can you exaggerate the height of a jump in a photograph
    10·1 answer
  • What will be the result of running the following code fragment? int year = 0; double rate = 5; double principal = 10000; double
    14·1 answer
  • Match the context details with the pattern that applies.
    7·1 answer
  • How can blockchain be used to support sustainable business practices?
    8·1 answer
  • Call of duty vanguard, war zone , fornite, gta what’s your favorite
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!