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
ZeroIt is a function that takes one argument and returns no value. The argument is a pointer to int. The function stores the val
Sedbober [7]

Answer:

zeroIt(&x);

Explanation:

The statement that sets the value stored in x to zero by invoking the function zerolt is given below

zeroIt(&x);

The zeroIt function is also given below for better understanding.

void zeroIt(int *x) {

   *x = 0;

}

As seen, the function takes an argument with integer variable type, which is a pointer, denoted by the asterisk symbol (*x).

The ampersan sign (&x) is used to access the variable whose value can then be stored.

7 0
3 years ago
What is the output of the following code snippet if the variable named cost contains 100? if cost < 70 or cost > 150 : dis
DanielleElmas [232]

Answer:

The output is: Your cost is  100

Explanation:

Given

The above code snippet

and

cost = 100

Required

Determine the output of the code

if cost < 70 or cost > 150

The above condition checks if cost is less than 70 or cost is greater than 150

This condition is false because 100 is neither less than 70 nor is it greater than 150

So, the else statement will be executed.

discount = cost

Which means

discount = 100

So, the print instruction will print: Your cost is  100

6 0
3 years ago
A semiconductor kit is used on a
iragen [17]

The correct answer is PSC motor.

If you need more help, you can check on quizlet, I learnt about ecd from there lol

5 0
3 years ago
PLEASE HELP!!! What are the benefits of online notebooks? Check all that apply.
Kipish [7]

They allow users to store files.

They allow users to share files.

They help users organize assignments.

They allow users to clip information from web pages.

4 0
2 years ago
Read 2 more answers
List 5 ways by which Artificial intelligence (AI) can be used to drive our business.​
andreyandreev [35.5K]

Answer:

start a website

Explanation:

true

5 0
2 years ago
Other questions:
  • Assume that getPlayer2Move works as specified, regardless of what you wrote in part (a) . You must use getPlayer1Move and getPla
    14·1 answer
  • after installing a secondary hard drive what needs to be done to the hard drive and what do these two task do?
    9·1 answer
  • Create an instance of your queue that accepts java.lang.String Objects. Starting with an empty queue, use the enqueue(E e) metho
    15·1 answer
  • A corporation needs an operating system that allows the various teams in its office to network and collaborate on projects. Whic
    10·1 answer
  • Can anyone can tell me and explain me the answer of it please .<br>thanks
    9·1 answer
  • A driving school uses this rule to estimate how many lessons a learner will require.
    9·1 answer
  • Programs for embedded devices are often written in assembly language. Some embedded processors have limited instructions, like M
    5·1 answer
  • Hello everyone. New ppl on Ro.blox? I want to play sometime.
    8·2 answers
  • Can someone help me answer this, I can’t fail tysm :)
    11·1 answer
  • which of the following commands can be used to display any email messages awaiting delivery alongside the reason that they were
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!