Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Assignment 3

CPS 196 — Introduction to Computer Programming

Reading

Lecture 1 to 11, Lab 1 to 10 and Assignment 1 & 2

Logistics

Academic  Integrity:   You may discuss this assignment with others.  However, all work that you

submit must be your own:  after discussing the assignment with others, you should write up your work (including both documentation and code) alone.

This project gives extra 5% bonus points to your final grade.

Exercises

For this assignment, you will need to apply the program-design process discussed in lecture (and practiced in Lab 4) to create the requested program.

For this assignment, you will write a program that simulates a simple word-guessing game, similar  to Hangman (without the pictures) or television’s Wheel of Fortune (without the money and prizes). The idea is that the program will stOre” a secret phrase, and the user will try to discover the phrase by guessing one letter at a time.

For the purposes of this assignment, your program can have a single secret phrase that it uses each time the program runs. You may use any secret phrase you like, as long as it contains at least 15 characters, including at least one space (e.g﹒ , multiple letters).

● After each guess, the program should show the current status of the user’s guesses, using

dashes to indicates unguessed letters. For example, if the secret phrase is magical mystery tour and the user has already guessed the letters b, y, and t, then the program should display:

-------  -y-t--y  t---

Any spaces in the phrase should automatically be included  (i.e., the user doesn’t have to guess them).

You should keep track of the number of guesses the user makes.  (If a user re-guesses a letter previously guessed, the new guess is still counted.)

If, after the 20th guess, the user still hasn’t completely discovered the phrase, the program should display a consolation message and end the game.  The consolation message should include the secret phrase.

If the user discovers the secret phrase by the 20th guess, you should display a congratulatory message, along with the number of guesses the user took.

General Hint

You’ll probably nd it easiest to have two lists: one holds the characters of the secret phrase, while the other holds the characters of the current status. When a user guesses a letter, look through the elements of the former to determine whether you need to change anything in the latter.

What to turn in (and how)

You should submit the following to Blackboard:


Documentation for the program-design process (handwritten is fine, as long as it is legible) Given   the nature of this assignment, you do not need to develop an examples of the complete dialog,     but you should sketch out the basics (e.g., what happens after an intermediate guess, what the   consolation and congratulatory messages look like). You do not need to show detailed calculations for an example.

Your algorithm description should outline the basic subtasks necessary f or solving the problem, but you do not need to provide specific details such as loop index and the like.

Your program (e.g., the .py file that contains your commented code)

Sample runs (.txt file saved from the Shell window) that demonstrate your program’s behavior.