Question: Advanced level school Python programming. need helps.tq 1 Wordle is a popular word game where players are made to guess a five-letter word within six

Advanced level school Python programming. need helps.tq

1 Wordle is a popular word game where players are made to guess a five-letter word within six tries. The task is to recreate the game in Python. Task 1.1 Write a function get_word (filename) that: - accepts filename, a string representing the name of a file containing one or more five letter words; - randomly chooses a word from the file and returns the word. Test the function with words . txt. For example, get_word('words.txt') should return a word randomly chosen from words . txt. Task 1.2 Write a function check_validity (guess) to check if guess is valid. A valid guess should: - contain only lowercase letters; - not contain numbers, punctuation, spaces or any other symbols; - be exactly five letters in length. The function would return True if guess is valid and False if not. Test the function fully with suitable test cases. Task 1.3 Write a function check_guess (guess, word) that: - accepts two parameters: - guess: a string that represents what the player guessed; - word : a string that represents the answer; - creates two lists: - the list correct is a list of indices of letters in guess that are in word and in the correct position; - the list in_word is a list of indices of letters in guess that are in word but not in the correct position; - returns a list containing correct and in_word Test the function with the following test cases: check_guess ('maple', 'apple') should return [[2,3,4],[1]]. check_guess ('poppy', 'apple') should return [[2],[0]]. check_guess('apple', 'apple') should return [[0,1,2,3,4],[]]. check_guess('apepe', 'apple') should return [[0,1,4],[3]]. Task 1.4 Write a function display_result (correct, in_word) to inform the player of the results of his guess. The function: - accepts two parameters, the lists correct and in_word; - outputs a string containing only the following characters: , , where represents a letter that is in the word and in the right position; * represents a letter that is in the word but not in the right position; represents a letter that is not in the word; The output of the function should be displayed to the player. Test the function with the following test cases: display_result ([2,3,4],[1]) should display '_*^^^' . display_result ([], [1]) should display '_*_'. '. Task 1.5 The function play_wordle() for the game can be found in Task1_5.txt. The function play_wordle () makes use of the functions you created in Tasks 1.1 to 1.4 to run the game. Copy the play_wordle () function from Task1_5.txt into your Jupyter Notebook. Run the proqram
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
