Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Background Information

This assignment tests your understanding of and ability to apply the programming concepts we have covered in the unit so far, including the usage of variables, input and output, data types, selection, iteration, functions and data structures. Above all else, it tests your ability to design and then implement a solution to a problem using these concepts.

Assignment Overview

You are required to design and implement a "Word Game" program in which the user must identify a randomly selected "password" from a list of 8 words. The 8 words are selected at random from the list of 100 words in the starter file (word_game.py) provided to you with this assignment brief. Please use the starter file as the basis of your assignment code.

The user has 4 attempts in which to guess the password. Whenever they guess incorrectly, they are told how many of the letters are the same between the word they guessed and the password. For example, if the password is "COMEDY" and they guessed "MOULDY", they would be told that 3/6 letters were correct due to the O, D and Y being the same. Note that a letter must be in the correct position to be correct. e.g. In the example above, both words contain the letter "M" but it is in a different position in the word so it is not counted as a correct letter.

Using this information, the user can make increasingly knowledgeable guesses and win the game by selecting the password within four guesses. If the user fails to select the correct word within 4 guesses, they lose the game.

Pseudocode
As emphasised by the case study of Module 5, it is important to take the time to properly design a solution before starting to write code. Hence, this assignment requires you to write and submit pseudocode of your program design as well as the code for the program. Furthermore, while your tutors are happy to provide help and feedback on your assignment work throughout the semester, they will expect you to be able to show your pseudocode and explain the design of your code.

You will gain a lot more benefit from pseudocode if you actually attempt it before trying to code your program - even if you just start with a rough draft to establish the overall program structure, and then revise and refine it as you work on the code. This back and forth cycle of designing and coding is completely normal and expected, particularly when you are new to programming. The requirements detailed on the following pages should give you a good idea of the structure of the program, allowing you to make a start on designing your solution in pseudocode.

Write a separate section of pseudocode for each function you define in your program so that the pseudocode for the main part of your program is not cluttered with function definitions. Ensure that the pseudocode for each of your functions clearly describes the parameters that the function receives and what the function returns back to the program.

It may help to think of the pseudocode of your program as the content of a book, and the pseudocode of functions as its appendices: It should be possible to read and understand a book without necessarily reading the appendices, however they are there for further reference if needed.

Only one function is required in this assignment (detailed later in the assignment brief).

Program Requirements

These requirements begin where the starter file ends - after defining the "candidateWords" list. In the following information, numbered points describe a core requirement of the program, and bullet points (in italics) are additional details, notes and hints regarding the requirement. Ask your tutor if you do not understand a requirement or would like further details.

1. Set up the game by creating a list of 8 randomly selected words from candidateWords and then randomly select one of those words to be the password. Also create a boolean variable to keep track of whether or not the game has been won (set it to False) and an integer variable to keep track of the number of guesses remaining (set it to 4).

- This assignment brief will assume variable names of "wordList", "password", "won" and "guessesRemaining" for the variables mentioned above.
- The "random.sample()" function can be used to randomly select a number of items from a list, and "random.choice()" can be used to randomly select just one item from a list.
- The won variable will be set to True if the password is guessed, and will help to control the loop (see Requirement 2) and decide which message to print at the end of the game (see Requirement 3).

2. Print a message to welcome the user, and then enter a loop that will repeat while
guessesRemaining is greater than 0 and won is False. The body of this loop must...
Print all of the words in wordList along with their corresponding index number, and then print the number of guesses remaining.
- The most efficient way to print all of the words in wordList is to use a "for" loop and the "enumerate()" function. See Lecture 3, Slide 38 for an example of this.
Prompt the user to choose one of the words by entering its index number (0-7), and reduce guessesRemaining by 1.
- Note that the user inputs an index number, not the word itself. To get the corresponding word, refer to that index number of wordList.
- Remember that the "input()" function always returns the user's input as a string - you will
need to convert it to an integer before you can use the value as an index number of wordList.

Print the selected word, and then check if it is the same as password.
If the words are the same, the user has guessed correctly: The program should print a "password correct" message and set the won variable to True.
If the words are not the same, the user has guessed incorrectly: Print a "password incorrect" message, then call the "compareWords" function to determine the number of matching letters before printing a message to tell the user how many letters are correct.

3. The last thing the program should do (after the body of the loop described in Requirement 2) is print a "you win" message if the won variable is True, or a "you lose" message if it is False.
- By the time the program reaches this point, either the loop ended because the user ran out of guesses
(and hence the won variable is still set to False), or because the user guessed correctly (and hence the
won variable was set to True as per Requirement 2.3).

The "compareWords" function
When the user selects a word that is not the password, the program needs to determine how many matching letters there are between the password and the selected word (see Requirement 2.3).

Your program must define a function named "compareWords" that receives two words (the password and the selected word) as parameters. It must determine the number of matching letters between the words, and return this number back to the program as an integer. It is up to you to design and implement the code necessary to implement this functionality.

The definition of the function should be at the start of the program (as it is in the starter file provided), and it should be called where needed in the program. Revise Module 4 if you are uncertain about defining and using functions, and be sure to implement it so that it receives and returns values exactly as described above. The function should return the number of matching letters - it should not print anything itself.

Attachment:- Assignment.rar

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M93090555
  • Price:- $120

Guranteed 48 Hours Delivery, In Price:- $120

Have any Question?


Related Questions in Programming Language

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As