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]
2 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]2 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
Default tab stops are set in word every _______ inch. a. ¾ b. ½ c. 1 d. ¼
Dennis_Churaev [7]
A) 3/4 inch Meow! XD
6 0
3 years ago
Explain why much of social media marketing is trial and error.
Ivahew [28]
The first thing that entrepreneurs need to realize is that the process and framework for making social media marketing work are different from traditional marketing, and trial and error certainly doesn’t work. Ric Dragon, an expert in online marketing, in his new book “Social Marketology<span>,” outlined the best set of steps I have seen so far for the new world:</span>
7 0
2 years ago
Dana downloads music into her computers random access memory, or ram, without authorization. this is?
lilavasa [31]
This is copyright infringement.
7 0
3 years ago
whenever I try to make an account it says it can't sign me up at this time or something- can you help?-
Rus_ich [418]

Answer:

You can try emailing tech support and describing your issue. In order to get the best help as quickly as possible, try providing screenshots of what happens when you sign in or describe everything you see on the screen when the problem occurs, and quote error messages directly when possible.

5 0
2 years ago
In symmetric encryption the same key is used to encrypt and decrypt a message. in asymmetric encryption different keys are used
Brrunno [24]

A useful advantage of Asymmetric encryption over symmetric encryption is that there is no secret channel necessary for the exchange of the public key, unlike in the symmetric encryption which requires a secret channel to send the secret key.  

Another advantage of Asymmetric encryption is that is has increased security. Asymmetric uses two different keys (Public and private) for both encryption and decryption of data while symmetric uses one.

5 0
3 years ago
Read 2 more answers
Other questions:
  • Create a pseudocode program that asks students to enter a word. Call a function to compute the different ways in which the lette
    9·1 answer
  • A form letter can be customized by using different fields in a __________.
    15·2 answers
  • How can you assess a website for currency?
    14·2 answers
  • When browsing using certain browsers, if a page is known to be malicious or using phishing techniques in the past a browser may
    5·1 answer
  • Which of these might be an example of an advertiser's target group?
    12·2 answers
  • What is up what everbody up to
    13·2 answers
  • Describe comm<br>unication cycle​
    15·2 answers
  • Consider the following method, which is intended to count the number of times the letter "A" appears in the string str.
    13·1 answer
  • How to share excel file for multiple users office 365?.
    7·2 answers
  • quizlet ann is a security professional for a midsize business and typically handles log analysis and security monitoring tasks f
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!