""" ------------------------------------------------- Project: Take-Away Game Standard: 91883 (AS1.7) v.1 School: Tauranga Boys' College Author: Ryan Piddock Date: XX/03/25 Python: 3.5 ------------------------------------------------- """ # Setup - us = user score, cs = computer score, rw = round win import random import time us = 0 cs = 0 rw = True round = 1 # Title - Introduces the game to the player print("Take-Away Game") name = input("What is your name?") print("Welcome,", name, ". This is the take-away game." ) print("I will pick a number between 1 and 1000, which you will have to guess.") print("You have 10 guesses, and I will tell you if your choice was higher or lower than the number I picked.") print("If you guess the number within 10 attempts, you win.") print("If you don't, I win.") print("The winner of this game is decided by who wins the most out of three rounds.") print("Good Luck!") # Game - The program while us < 2 and cs < 2: n = random.randint(1,1000) rw = False print("------------------------------------------------") print ("Round", round) print("Your Score:", us ) print("My Score:", cs) time.sleep(1) gn = 11 while gn > 1 and rw == False: print("I am thinking of a number between 1 and 1000...") print("Guess", (12 - gn)) guess = int(input("What is your guess?")) if guess < 1001 and guess > 0: if guess == n : print("You did it!") rw = True us = us + 1 elif guess > n : print("Lower") gn = (gn - 1) elif guess < n : print("Higher") gn = (gn - 1) else: print("Please enter a valid number") round = round + 1 if gn < 2 and rw == False: print("I win this time!") cs = cs + 1 # Win condition - Prints the result once the player or computer has achieved a score of 2 points print("------------------------------------------------") if us == 2: print("Your Score:", us, "My Score:", cs) print("You won! Nice Job!") else : print("Your Score:", us, "My Score:", cs) print("You lost! Better luck next time!")