#------------------------------------------------- # Project: Number Game # Standard: 91883 (AS1.7) v.1 # School: Tauranga Boys' College # Author: Alexander Rossiter # Date: THE DATE YOU COMPLETED THE CODE # Python: 3.5 #------------------------------------------------- #import libaries import random import time #variables number = 0 computer = 0 round = 0 round_on = "y" round_won = 0 guess = 0 amount_wins = 0 player1_winner = 0 computer_winner = 0 previous_num = 0 #intro print("WELCOME TO THE NUMBER GAME") time.sleep(2) name = input("Hey! Whats your name?") print("Hi", name, "welcome to the game, im the computer who you will be up against today!") time.sleep(2) print("Here are the rules to the game:") print("You are a player and get 10 guesses per round...") time.sleep(2) print("There are three rounds and to win you must win two of those rounds...") time.sleep(2) print("The aim of the game is to try guess the computers number...") time.sleep(2) print("The computers number will be inbetween 1-1000...") print("Each time you guess you get a higher/lower...") time.sleep(2) print("Once you guess the number you win the round, but if you lose then the computer wins!") print("now that the rules are over... lets play", name, "!") #loop while player1_winner < 3 and computer_winner <3 : computer = random.randint(1, 1000) if computer == previous_num : computer = random.randint(1, 1000) previous_num = computer round_won = 0 guess = 0 while round_on == "y" : number = int (input("Whats number do you guess?")) #guesses guess += 1 if guess > 9: print("Thats ten guesses!") computer_winner +=1 round +=1 break #win if number == computer : print("Wow your taleneted! This win is to you!") round_won += 1 player1_winner += 1 round += 1 break #Higher/lower elif number > computer: print("Guess lower!") guess +=1 else : print("Guess higher!") #the winner while round == 3 : if player1_winner > computer_winner : print("You win!") if computer_winner > player1_winner : print("computer wins!", name, "couldnt guess the right number :(") break