#------------------------------------------------- # Project: Guessing Game # Standard: 91883 (AS1.7) v.1 # School: Tauranga Boys' College # Author: Stefan Pendergrast # Date: 15/03/2024 # Python: 3.5 #------------------------------------------------- #Sequences import random import time # Variables reset_guesses = 0 rounds = 3 player_score = 0 computer_score = 0 round = 0 remaining_guesses = 0 GUESSES = 10 # Explaining the game name = input("What Is Your Name? ") # Use Of Function def Get_names(name) : time.sleep(0.5) print("") print("Hello " + name + " Welcome To The Guessing Game") Get_names(name) print("") print("I am thinking of a number from 1, 1000...") time.sleep(1) print("") #Outer loop while True: computer_number = random.randint(1,1000) remaining_guesses = GUESSES #Loop For If The Game Is Over and Player Wins if round == 3 and player_score > computer_score : print("Game Over,", name, "Wins!") break #Loop For If The Game Is Over and Computer Wins if round == 3 and player_score < computer_score : print("Unlucky", name, "Computer Wins!") break play = input("Would you like to begin the round? (y/n) ") #While Play = y Loop while play == "y" : remaining_guesses = remaining_guesses print("") #Checking for interger validation while True : try: guess = int(input("Choose A Number: ")) if guess < 1 or guess > 1000 : print("Is that number between 1 and 1000?") time.sleep(1) print("") print("No I didnt think so") else: break # If the user doesnt put in a number at all except: print("How do you think im gonna proccess if you didnt even put a number in my bro") # Loop For If Number Is Correct if guess == computer_number : print("") print("Correct") player_score = player_score + 1 round = round + 1 print("") print( name + "'s", "Score =", player_score) print("") print("Computer Score =", computer_score) print("") break #Loop For If Guess Is Higher Than Number elif guess > computer_number : print("") print("Lower!") remaining_guesses = remaining_guesses - 1 print("") print("You have", remaining_guesses, "Guesses Remaining!") #Loop For If Guesses Are less than 0 if remaining_guesses <= 0 : print("") print("Sorry", name, "You lose this round") print("") print("The answer was", computer_number) round = round + 1 computer_score = computer_score + 1 print("") print(name + "'s", "Score =", player_score) print("") print("Computer Score =", computer_score) print("") break elif guess < computer_number : print("") print("Higher!") remaining_guesses = remaining_guesses - 1 print("") print("You have", remaining_guesses, "Guesses Remaining!") #Loop For If Guesses Are less than 0 if remaining_guesses <= 0 : remaining_guesses = 0 print("") print("Sorry", name, "You lose this round") print("") print("The answer was", computer_number) round = round + 1 computer_score = computer_score + 1 print("") print(name + "'s", "Score =", player_score) print("") print("Computer Score =", computer_score) print("") break