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 of the following circuits has an equivalent resistance of 30 Ω?
zimovet [89]

Answer:

the one on the bottom left

Explanation:

10+20=30

The other 20 does not matter. electricity takes one path, always the path with less resistance but here there both the same.

3 0
3 years ago
Read 2 more answers
When you begin creating a new powerpoint presentation, you need to select a ____.?
valina [46]
You would need to select a theme
5 0
3 years ago
True or False? Any edition or version of Windows can join a domain.
Veseljchak [2.6K]

Answer: TRUE! 100%

If I was helpful i would to be rated brainliest please thank you!

Explanation:

8 0
2 years ago
While adding information to the employee information database, Neil's computer crashed, and the entire database was erased. Whic
Varvara68 [4.7K]

Answer:

logic bombs

Explanation:

logic bombs -

It consists of certain coding , which is put into the software and will perform certain malicious function at the very correct time, is known as logic bomb ,

they are also known as time bomb.

It is a time of virus , but gets activated as soon as all conditions are met , which is coded in to the software.

Hence , from the given scenario of the question,

The correct term is logic bomb.

6 0
3 years ago
Which of the following is a goal of summarizing?
zhannawk [14.2K]

Answer:

b

Explanation:

its B mygee

5 0
3 years ago
Other questions:
  • How do I type the integral symbol?
    7·2 answers
  • Explain what might happen if two stations are accidentally assigned the same hardware address?
    15·1 answer
  • Jimmy wrote the procedure scoreToGrade which accepts as a parameter score - a quiz score in the range 0-100. The procedure is su
    8·1 answer
  • You are using a PowerPoint template from your school to present your research findings in front of the class. What would you do,
    13·2 answers
  • The ________ utility automatically creates duplicates of your libraries, desktops, contacts, and favorites to another storage lo
    6·1 answer
  • ―Connectivity is Productivity‖- Explain the statements.
    8·1 answer
  • PLEASE HELP ILL GIVE BRAINIEST
    6·2 answers
  • I'm working on an assignment for my computer science class (Edhesive) and when I run the code, there are no errors. But when I t
    11·1 answer
  • Which Operating System is used most often in households?
    6·2 answers
  • Fill the labels!! Please quickly I need help quickly
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!