############################################################ # COMPUTER SCIENCE UNDERGRADUATE SCHOLARSHIP EXAM # UNIVERSITY OF WAIKATO # PYTHON PROGRAMMING LANGUAGE # JULIANO TAVARES (TAURANGA BOYS' COLLEGE YR 13) ############################################################ # Importing necessary modules import random # Welcome user to the game print ("Welcome to Animal Wordle!") # List of animals for the game animals = ["duck", "goat", "lion", "frog", "deer", "swan", "wolf", "crab"] # Get a random animal from the list above random_animal = random.choice(animals) # print(random_animal) # Set variables (guesses) min_guesses = 0 current_guess = 6 # print("Random Animal is:", random_animal) # Give user instructions and some history about the game print (''' Wordle is a word game that was created and developed by Welsh software engineer Josh Wardle. In the original version of Wordle, players have six attempts to guess a five-letter word, with feedback given for each guess in the form of coloured tiles indicating when letters match or occupy the correct position.''') print (''' In Animal Wordle, players have six attempts to guess a four-letter animal, with feedback given for each guess indicating when letters match or occupy the correct position. If the character is in the correct position, it is indicated with a hash (#). If the character is in the correct position, it is indicated with a hyphen (-). If a character is incorrect, it is represented with a full stop (.).''') # Store the user's name in the name variable name = input("Please enter your name: ") # Get info on whether user wants to play or not play = input(f"Hi {name}! Would you like to play Wordle? [y/n]: ") # Play if user wants to play or quit if user doesn't want to play if play == "y": print("Perfect, let's start") else: print("No Problem, Have a great rest of your day.") quit # Run the game itself while current_guess > min_guesses: print(f"You have {current_guess} guesses left to get the word.") l1, l2, l3, l4 = input("Enter four letters separated: ").split() print("Letter 1: ", l1) print("Letter 2: ", l2) print("Letter 3: ", l3) print("Letter 4: ", l4) if (l1 + l2 + l3 + l4 == random_animal): print("Result: .....") print("Woohoo! You guessed the word correctly!") break else: print("Whoops, no letters are correct! Keep guessing.") current_guess -= 1 if current_guess <= min_guesses: print("You have 0 guesses left! You lost.")