联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Python编程Python编程

日期:2024-08-27 10:45

Computer Science 11 - Unit 5

Inquiry Question

Can the pencil and paper game of Hangman be created and played in Python?

Are there any differences between the paper version and the Python version?


General Instructions

Hangman is a paper and pencil guessing game. One player thinks of a word, phrase, or

sentence and the other player attempts to guess it by suggesting letters. The player has a

limited number of incorrect guesses. For each incorrect guess, a part of the stick figure on the

noose is added. Once a full stick figure is drawn, the game is over, and the guessing player

has lost.

Using Python’s “random” module, as well as functions and loops, can you write a Python

program in which a user guess words that the computer has chosen randomly?

Page 1 of 5

Computer Science 11 - Unit 5


Materials you’ll need:

● Pencil

● Computer

Project submission:

Submit the completed pages of this project as well as the .py code file for your Hangman program.

Design Specifications

Use at least one list (to store guesses made).

Only accept valid guesses (letters only). Lowercase and uppercase letters should be

accepted.

Use at least one loop, to prompt the user for each guess.

Keep track of incorrect guesses, the game is over and the player has lost once the user

has made more than the allowed number of incorrect guesses.

Do not allow a guessed letter to be guessed again.

After each guess, output the incomplete word (use underscores for hidden letters).

Choose a word or phrase randomly (can be from a list of hard coded options). Use

Python’s “random” module.

Define and use at least 3 functions.

Bonus Options

Find a better way to select random words other than hard coding them into the program.

Could you download a dictionary of words and use that? Could you query a website for a

random word?

[HARD] Create a graphical user interface (GUI) for your Hangman game using the

Tkinter module.

Page 2 of 5

Computer Science 11 - Unit 5

Hints and Resources

Here is a full example of how your program might look when you run it in the console.

Page 3 of 5

Computer Science 11 - Unit 5

Questions

Given a list of random words stored in a variable “WORDS”, how will you choose a random word

from the list?

Using pseudocode, write a function to detect whether the user has correctly guessed the entire

word. The function should accept a list of guesses, as well as the word the user is trying to

guess.

Page 4 of 5

Computer Science 11 - Unit 5

What are the differences between your computer version of Hangman and the traditional pencil

and paper version? Why are there these differences?

Did you struggle with any particular part of this project? How did you finally resolve the issue?

Page 5 of 5


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp