#------------------------------------------------- # Project: guessing game # Standard: 91883 (AS1.7) v.1 # School: Tauranga Boys' College # Author: Rhys Peter David Mason # Date: THE DATE YOU COMPLETED THE CODE # Python: 3.5 #------------------------------------------------- import random guess = 0 round = 1 answer = 0 play = input("do you want to play? y/n: ") rounds = 3 guessTIMES = 10 psco = 0 csco = 0 name = input("what is your name: ") print("hello ", name," welcome to the guessing game") start = input("whould you like to start? y/n: " ) while play == "y": answer = random.randint(1,1000) if start == "y": while guessTIMES > 0: guess = int(input("pick a number between 1 - 1000: ")) #this is the winning code below if guess == answer: print("you are correct!!") print(" ") psco = psco + 1 round = round + 1 print("the pc's score is ", csco," your score is", psco) if psco == 2: print("that is the end of the game") print(name, "your score was", psco,", the computers score was", csco) if psco > csco: print(" ") print("you beat the computer!") else: print(" ") print("better luck next time") print(" ") start =input("do you want to start the next round y/n: ") answer = random.randint(1,1000) if start != "y": break #this is the guess is lower than answer code below if guess > answer: print(" ") print("lower") guessTIMES = guessTIMES - 1 if guessTIMES == 0: print(" ") print("you lose") print("the answer was", answer) csco = csco + 1 round = round + 1 print("the pc's score is ", csco, name, " your score is", psco) print(" ") if psco == 2: print("that is the end of your 3 rounds") print(name, "your score was", psco,", the computers score was", csco) if psco > csco: print("you beat the computer!") else: print("better luck next time") start =input("do you want to start the next round y/n: ") answer = random.randint(1,1000) if start != "y": break if guess < answer: print("higher") guessTIMES = guessTIMES - 1 if guessTIMES == 0: print("you lose") print("the answer was", answer) csco = csco + 1 round = round + 1 print("that is the end of the game") print(name, "your score was", psco,", the computers score was", csco) if psco > csco: if psco or csco == 2: print("you beat the computer!") break else: print("better luck next time") break print("the pc's score is ", csco, name, " your score is", psco) start =input("do you want to start the next round y/n: ") answer = random.randint(1,1000) if start != "y": break