""" ------------------------------------------------- Project: Number guessing game Standard: 91883 (AS1.7) v.1 School: Tauranga Boys' College Author: Zane levick Date: THE DATE YOU COMPLETED THE CODE Python: 3.5 ------------------------------------------------- """ #modules import os import random import time #seting Base varibles reset_guesses = 0 rounds = 3 user_score = 0 AI_score = 0 round_won = True round = 1 play_again = "y" #functuions def title(): print(""" _ _ _ _ _ _ | | | | | | | | | | (_) | | | | ___ | | ___ ___ _ __ ___ ___ | |_ ___ _ __ ___ _ _ _ __ _ _ _ __ ___ | |__ ___ _ __ __ _ _ _ ___ ___ ___ _ _ __ __ _ __ _ __ _ _ __ ___ ___ | |/\| | / _ \| | / __| / _ \ | '_ ` _ \ / _ \ | __| / _ \ | '_ ` _ \ | | | | | '_ \ | | | || '_ ` _ \ | '_ \ / _ \| '__| / _` || | | | / _ \/ __|/ __|| || '_ \ / _` | / _` | / _` || '_ ` _ \ / _ | \ /\ /| __/| || (__ | (_) || | | | | || __/ | |_ | (_) | | | | | | || |_| | | | | || |_| || | | | | || |_) || __/| | | (_| || |_| || __/\__ \\__ \| || | | || (_| | | (_| || (_| || | | | | || __/ \/ \/ \___||_| \___| \___/ |_| |_| |_| \___| \__| \___/ |_| |_| |_| \__, | |_| |_| \__,_||_| |_| |_||_.__/ \___||_| \__, | \__,_| \___||___/|___/|_||_| |_| \__, | \__, | \__,_||_| |_| |_| \___| __/ | __/ | __/ | __/ | |___/ |___/ |___/ |___/ """) def play_game(): global user_score, AI_score # Start of the game loop for round_number in range(1, rounds + 1): break #Intro to game title() play_game() #input name NAME = input("What is your name player?: ") print("Welcome {} to my number guessing game".format(NAME)) play_again = input("would you like to play?: ") #start of round loop while play_again == "y" : number_to_guess = random.randint(1,100) round_won = False guesses = reset_guesses #printing the score and round print("The current round is {} and the current score is {}".format(round,user_score)) time.sleep(2) #start of guess loop while not round_won and guesses <10: user_guess = int(input("Pick a number: ")) if user_guess == number_to_guess: user_score += 1 print("Congratulations! You've guessed the number!") round_won = True else : print("Wrong guess!") guesses += 1 if guesses == 10 : AI_score += 1 print("You've run out of guesses. The AI gets a point!") elif user_guess < number_to_guess: print("Try a higher number!") elif user_guess > number_to_guess: print("Try a lower number!") elif AI_score or user_score == 2 : print ("This is the ai's score {} this is your score {} {} ".format(AI_score,NAME,user_score)) round_won = True break