''' -------------------------------------------------------------- Project : Take Away Standard: TE PUNGA - Programming Assessment School: Tauranga Boys' College Author: James Lansdown Date: 10/03/2025 start. -------------------------------------------------------------- ''' #Imports the time and a random number. import random import time #Variables Score1 = 0 Score2 = 0 Rounds = 0 Chips_Left = 0 Chips_Left2 = 0 #Asking for the players names. Player1 = input("What is the first players name? ") Player2 = input("What is the second players name? ") #Rules for the game print("Welcome", Player1, "and", Player2, "to TAKE AWAY") time.sleep(1) print("The rules are as follows.") time.sleep(1) print("You will first select how much rounds you want to play") time.sleep(1) print("Next you will be given a pot of a random number of chips.") time.sleep(1) print("You will select how much you want to take out of 1-3") time.sleep(1) print("And the player who takes the final chip wins.") Play = input("Would you like to play? Y or N? ") #Start of the first play loop. while Play == "y" or "Y" : Rounds_Want = int(input("How much rounds would you like to play? ")) Rounds = Rounds_Want #Asks how much rounds wanted to play. print("You have chosen", Rounds, "rounds.") Chips_Left = random.randint(21,39) #Generates a random number of chips from 21 to 39. print("There are", Chips_Left, " chips in the pot") Chips_Number1 = int(input("{} Choose out of 3 how much chips you want. ".format(Player1))) # The code below makes you pick a number from 1 to 3. if Chips_Number1 >= 4 : print("{} please pick a number between 1 and 3. ".format(Player1)) Chips_Number1 = int(input("{} Choose out of 3 how much chips you want. ".format(Player1))) #This code SHOULD restart the loop onto loop 2 for player 1. while Chips_Number1 <= 3 : Chips_Left = Chips_Left - Chips_Number1 while Chips_Left <= 0 : Rounds = Rounds = 0 + 1 print("Round {} Over.".format(Rounds)) print("{} lost".format(Player1)) Loop2 = input("Start next round? ") print("Next round starting now.") break # The code below starts the second player guess and play. print("There are {} remaining".format(Chips_Left)) print("{} your turn to now pick. ".format(Player2)) Chips_Number2 = int(input("{} Choose out of 3 how much chips you want. ".format(Player2))) if Chips_Number2 >= 4 : print("{} please pick a number between 1 and 3. ".format(Player2)) Chips_Number2 = int(input("{} Choose out of 3 how much chips you want. ".format(Player2))) elif Chips_Number2 <= 3 : Chips_Left = Chips_Left - Chips_Number2 while Chips_Left <= 0 : Rounds = Rounds = 0 + 1 print("Round {} Over.".format(Rounds)) print("{} lost".format(Player2)) Loop2 = input("Start next round? ") print("Next round starting now.") break print("There are {} remaining".format(Chips_Left)) Chips_Number1 = int(input("{} your turn to now pick. ".format(Player1))) #Start of loop 2 which doesn't work. The number doesn't restart and it just repeats the same phrase. Its the same as the above code. Loop2 = input("Are you ready to start? ") while Loop2 == "yes" or "Yes" : Chips_Left2 = random.randint(21,39) print(Chips_Left2) print("There are", Chips_Left2, " chips in the pot") Chips_Number1 = int(input("{} Choose out of 3 how much chips you want. ".format(Player1))) if Chips_Number1 >= 4 : print("{} please pick a number between 1 and 3. ".format(Player1)) Chips_Number1 = int(input("{} Choose out of 3 how much chips you want. ".format(Player1))) while Chips_Number1 <= 3 : Chips_Left2 = Chips_Left2 - Chips_Number1 while Chips_Left2 <= 0 : Rounds = Rounds = 0 + 1 print("Round {} Over.".format(Rounds)) print("{} lost".format(Player1)) print("Next round starting now.") Loop2 = input("Ready to start? ") print("There are {} remaining".format(Chips_Left2)) print("{} your turn to now pick. ".format(Player2)) Chips_Number2 = int(input("{} Choose out of 3 how much chips you want. ".format(Player2))) if Chips_Number2 >= 4 : print("{} please pick a number between 1 and 3. ".format(Player2)) Chips_Number2 = int(input("{} Choose out of 3 how much chips you want. ".format(Player2))) elif Chips_Number2 <= 3 : Chips_Left2 = Chips_Left2 - Chips_Number2 while Chips_Left2 <= 0 : Rounds = Rounds = 0 + 1 print("Round {} Over.".format(Rounds)) print("{} lost".format(Player2)) print("Next round starting now.") Loop2 = input("Ready to start? ") print("There are {} remaining".format(Chips_Left)) Chips_Number1 = int(input("{} your turn to now pick. ".format(Player1)))