Design and implement a word game program

Assignment Help Programming Languages
Reference no: EM132103086

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

Reference no: EM132103086

Questions Cloud

Construct a fish-bone chart using word or ms paint : Recommend to the ambulatory health service on how it can improve the services it offers in its walk-in urgent care clinic, based on your analysis.
Determine the amount of credit available : The company currently has 1,000 units in stock, and is performing "on budget." Determine the amount of credit available under the borrowing agreement
How does ambiguity make policymaking more difficult : Should laws say specifically what it is intended to do or should it be open to interpretation as the generations go by?
Determine the equivalent units of production : During June, a total of 31,200 units were completed and transferred to finished goods. Determine the equivalent units of production
Design and implement a word game program : CSP5110 Programming Principles - Edith Cowan University - design and implement a "Word Game" program in which the user must identify a randomly selected
Find an expression for the electric field : Charge Q is uniformly distributed along a thin, flexible rod of length L. The rod is then bent into the semicircle shown in the figure (Figure 1) .
How does the culture view child-rearing : How does the culture view child-rearing? Research issues of feeding, sleeping, extended family relationships, and play.
Create a jing tutorial multimedia-based presentation : Describe the specific example or resource selected (title given), the age group intended for, and the content area it covers.
What is the electric flux through the surface of the box : Charges of 3.0 nC, -2.0 nC, -7.0 nC, and 1.0 nC are contained inside a rectangular box with length 1.0 m, width 2.0 m, and height 2.5 m.

Reviews

len2103086

9/3/2018 3:08:31 AM

Functionality These marks are awarded for submitting source code that implements the requirements specified in this brief, in Python 3. Code which is not functional or contains syntax errors will lose marks, as will failing to implement requirements as specified. 10 Code Quality These marks are awarded for submitting well-written source code that is efficient, well- formatted and demonstrates a solid understanding of the concepts involved. This includes appropriate use of commenting and adhering to best practise. 5 Total: 20

len2103086

9/3/2018 3:08:21 AM

Marking Key Marks are allocated as follows for this assignment. Criteria Marks Pseudocode These marks are awarded for submitting pseudocode which suitably represents the design of your source code. Pseudocode will be assessed on the basis of whether it clearly describes the steps of the program in English, and whether the program is well structured. 5

len2103086

9/3/2018 3:08:05 AM

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.

Write a Review

Programming Languages Questions & Answers

  Create a new class called soda that is also a beverage

Create a new class called Soda that is also a caffeinated beverage by default it will have no option for condiments. Have it called in main. Main also calls the old addLemon function on Tea so that the customer gets two lemons.

  Program by bernstein-s conditions to get maximum parallelism

Restructure program by using Bernstein's conditions in order to get maximum parallelism between processes. Specify which of the three conditions is not satisfied.

  Designing menu for administrator to simulate transmissions

Design a menu which permits administrator to simulate transmissions of information by manually typing in login or logoff data.

  Write a mortgage calculator in perl

The following formula is used to calculate the fixed monthly payment (P) required to fully amortize a loan of L dollars over a term of n months at a monthly interest rate of c. [If the quoted rate is 6%, for example, c is .06/12 or .005].

  Create an application that manipulates a billboard sign

Create an application that manipulates a billboard sign. The set method allows user to select a predefined message. Also, user can create his message.

  Create an ms word document containing a hierarchy chart

First, create an MS Word document containing a hierarchy chart and a data flow diagram to organize your program modules. Second, create a pseudocode program using Notepad++ to solve this problem.

  Creating loop to find number of items bought based on price

Make a block using a loop that will find the number of items that can be bought based on the price of the item and the total amount available to spend.

  Payroll program for a large organization

You have been tasked with building a payroll program for a large organization with offices spread across the United States. The company has one larger data center that each office connects to via a wide area network (WAN)

  Iimplement a class called monetarycoin

Create an implement a class called MonetaryCoin that is derived from the class Coin class. Store a value in the in the monetary coin that represents its value.

  Discuss the requirements of a linear programming model

Discuss the requirements of a linear programming (LP) model. Provide an example of an LP model and define each variable used. What are the key steps that need to be considered when formulating an LP problem

  Write a perl program that given a dna string

Write a Perl program that given a DNA string, prints out the 20 characters upstream of the start codon ATG

  Characteristics used for biometric user authentication

You have just been promoted to manager of computer security for large enterprise (XYZ Corporation). Your first project as security manager is to estimate principal physical characteristics used for biometric user authentication.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd