""" ------------------------------------------------- Project: Take-Away Game Standard: 91883 (AS1.7) v.1 School: Tauranga Boys' College Author: Ryman Song Date: 03/03/2025 Python: 3.5 ------------------------------------------------- """ import random #Variables rounds = 3 playerscore = 0 AIscore = 0 round = 1 #Title print("Number Guessing Game") #Asks the player for their name and explains the game to them. name = input('What is your name? ') print(f"Hello {name}, this is a guessing game where you have 10 guesses to try to guess the random number between 1 and 1000. It will tell you higher or lower based on your guess. The game will be a best out of three. Have fun! :p") #Generates a random number and starts the game while playerscore < 2 and AIscore <2 : target = random.randint(1,1000) guesses = 0 print("Round", round) print("Current Score:") print("Player Score:", playerscore) print("Ai Score:", AIscore) while guesses < 10 : try: number = int(input("Guess between 1 and 1000: ")) if number < 1 or number > 1000: print("Invalid number try again") continue guesses += 1 if number > target : print("Lower") elif number < target : print("Higher") else: print("Wowzers you good") break except ValueError: print("Please enter a valid number between 1 and 1000.") continue if number == target: playerscore += 1 print(f'You win good job wowzer, {name}: {playerscore}') print(f'loser bad, Ai: {AIscore}') else: AIscore += 1 print(f'The number was {target} You lose {name}: {playerscore}') print(f'Ai: {AIscore}') round += 1 print("Final Score:") print(f'{name}: {playerscore}') print(f'Ai: {AIscore}')