#------------------------------------------------------------------ #Project: Mini Project Guess The Number #Standard: 91883 (AS1.7) v.1 #School: Tauranga Boys' College #Author: Shevon Julian Joseph #Date: 11 03 2024 #Python: 3.5 #------------------------------------------------------------------- import random import time #_ _ _Welcome_ _ _ print("Welcome To Guess The Number.") #_ _ _player name checking_ _ _ while True: Player_name = input("What is your name? ") if Player_name.isalpha() == True : break else : print("Your name is not vaild, Try again!") #_ _ _Intro_ _ _ print("Hello {}, it is now time to guess a number.".format(Player_name)) time.sleep(2) print("You have 10 guesses per round.") time.sleep(2) print("Its {} VS Me...".format(Player_name)) time.sleep(2) print("GAME STARTS") time.sleep(2) #_ _ _Game starts_ _ _ def guessed_number(max_attempts = 10): guessed_number = random.randint(1,1000) attempts = 0 while attempts < max_attempts: player_guess = int(input("Enter your guessed number : ")) attempts += 1 if player_guess < guessed_number: print("Too low, Try again!") print() elif player_guess > guessed_number: print("Too high, Try again!") print() else: print("Congrats! you guessed the number ", guessed_number) print() return True print(f"Oop's you ran out of your ",attempts, "attempts! The number was ", guessed_number) def play_game(num_rounds = 3, max_attempts = 10): print("Welcome to number gsessing game.") player_score = 0 computer_score = 0 for round_num in range (1, num_rounds + 1): print(f"\n Rounds {round_num} :" "Player score : ",player_score ,"Computer score : ", computer_score) if guessed_number(max_attempts): print("You won this round") player_score += 1 else: print("You lost this round") computer_score += 1 print("\n ...GAME OVER... ") print("THANKS FOR PLAYING MY GAME") play_game()