1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
maw [93]
3 years ago
8

This assignment is to code a simple hangman game. The game should choose a random word out of a list of words that are coded int

o the program and ask for guesses. You should include a total of 20 words, lengths ranging from 4 to 12 letters long . Each time a person guesses wrong, it should decrement the total number of guesses (5 incorrect guesses allowed, on the 6th incorrect guess the game ends with a loss). When the user guesses the word or if they lose, they have the option of playing again. The expected output should be text based.
Computers and Technology
1 answer:
pshichka [43]3 years ago
7 0

Answer:

Programming language not stated.

I'll use python for this question

Explanation:

import random

# library that we use in order to choose

# on random words from a list of words

words = ['rain, 'computer', 'science', 'program, 'python', 'mathematics', 'player', 'condition','reverse', 'water', 'board', 'geeks','learn','school','days','scholar','collar','flood','house','flies']

# Function will choose one random word from this list of words

word = random.choice(words)

print("Guess the word")

guesses = ''"

# 5 turns

turns = 5

while turns > 0:

# counts the number of times a user fails

failed = 0

# all characters from the input word taking one at a time.

for char in word:

# comparing that character with the character in guesses

if char in guesses:

print(char)

else:

print("_")

# for every failure 1 will be incremented in failure

failed += 1

if failed == 0:

# user will win the game if failure is 0 and 'You Win' will be given as output

print("You Win")

# this print the correct word

print("The word is: ", word)

break

# if user has input the wrong alphabet then it will ask user to enter another alphabet

guess = input("guess a character:")

# every input character will be stored in guesses

guesses += guess

# check input with the character in word

if guess not in word:

turns -= 1

# if the character doesn’t match the word then “Wrong” will be given as output

print("Wrong")

# this will print the number of turns left for the user

print("You have", + turns, 'more guesses')

if turns == 0:

print("You Loose")

You might be interested in
Which is the most efficient way to insert a circle into a slide?
Alinara [238K]
Go to insert < shapes < ellipses < get yer circle
8 0
3 years ago
Paula is working on a project for an iOS app that will show action clips with special effects to promote a new musical drama. Th
Goryan [66]

Answer:

she is creating a effective app.

Explanation:

6 0
3 years ago
Complete the implementation of the following methods:__init__hasNext()next()getFirstToken()getNextToken()nextChar()skipWhiteSpac
andrey2020 [161]

From method names, I am compelled to believe you are creating some sort of a Lexer object. Generally you implement Lexer with stratified design. First consumption of characters, then tokens (made out of characters), then optionally constructs made out of tokens.

Hope this helps.

6 0
3 years ago
What is depth of field? How can you adjust the depth of field in a photograph?
jarptica [38.1K]
First, you want to reduce the light so you can use a wider aperture then, zoom the lens in to enlarge the subject and move a little closer to the subject finally, switch to aperture-priority mode and select a large aperture like f/4 
6 0
3 years ago
______ uses the internet to shift activities from the user's computer to computers on the internet.
Genrish500 [490]

Answer:

internet

Explanation:

this is called networking

6 0
2 years ago
Other questions:
  • The email program shipped with Microsoft office
    15·1 answer
  • Drag the tiles to the correct boxes to compete the pairs.
    12·2 answers
  • How does a hard drive work?
    5·1 answer
  • Which educational qualification would help a candidate get a job as a computer systems engineer? a.certificate
    6·1 answer
  • For this question you must write a java class called Rectangle and a client class called RectangleClient. The partial Rectangle
    14·1 answer
  • How did the new technologies of WWI affect soldiers fighting on the front lines? Please include at least three examples of new t
    5·1 answer
  • A void function can return any value. TRUE FALSE
    8·1 answer
  • viết phương trình nhập vào bàn phím một dãy số nguyên a1,a2 ....ăn gồm n phần tử nguyên hãy đếm xem trong dãy a có bao nhiêu phầ
    7·2 answers
  • Make a Flow Chart From this C Programming Language Code
    14·1 answer
  • Why do we need to use a VPN service?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!