""" ------------------------------------------------- Project: Take-Away Game Standard: 91883 (AS1.7) v.1 School: Tauranga Boys' College Author: Shia Abdul-Coley Date: 6/03/2025 Python: 3.5 ------------------------------------------------- """ # Libraries and variable setup import random wins = 0 losses = 0 number = 0 # Asks for name; prints a greeting name = input("What is your name?\n") play = input(f"Hi {name}!\nIn this game you will have to guess the number I'm thinking of between 1 and 1000.\nI'll provide if you are higher or lower than my number, and you'll have 10 guesses.\nWould you like to play a best of 3 match? (y/n)\n") # Prints a bonus message and ends the program if you do not agree if play != "y": print(":(") quit() # Continues game loop if you have not won or lost 2 games while wins < 2 and losses < 2: # Initates the game guesses = 1 target = random.randint(1, 1000) # Start of game loop while guesses <= 10: # Asks for a number, checks the validity number = 0 while number == 0: number = int(input(f"\nGuess {guesses}/10\nGuess!\n")) if number < 1 or number > 1000: print("Invalid number!") number = 0 # Replies with feedback, breaks the loop if correct if number > target: print("Lower!") elif number < target: print("Higher!") else: print("Correct!") break # Increases the guess count by 1 guesses += 1 # Comments on how the game went if number == target: wins += 1 print(f"\nNice win!\n{name}: {wins}\nComputer: {losses}") else: losses += 1 print(f"\nThe number was {target}, I got you that time...\n{name}: {wins}\nComputer: {losses}") # Final results print(f"\n--------------------\n\nFinal score:\n{name}: {wins}\nComputer: {losses}") if wins > 1: print("Nice job!") else: print("Better luck next time!")