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
write a method that will return a person's age entered by keyboard. You will need to include at least one instance variable in t
slamgirl [31]

Answer:

This JAVA program shows the implementation of instance variable and methods.

import java.util.Scanner;

import java.lang.*;

public class Person {    

   Scanner sc = new Scanner(System.in);    

   // instance variable declared without static keyword and outside of all methods

   int age;    

   void getAge()

   {

       System.out.println("Enter your age");

       age = sc.nextInt();

   }    

   void display()

   {

       System.out.println("Entered age is " + age);

   }    

   public static void main(String args[]) {        

       Person ob = new Person();        

       ob.getAge();

       ob.display();

   }

}

OUTPUT

Enter your age

45

Entered age is 45

Explanation:

A class contains its own variables and methods. An instance variable is declared inside the class and outside of all the methods contained in that class.

As specified in the question, the class Person contains one instance variable age and two methods, along with main() method.

Along with the instance variable age, an object of the Scanner class is created to enable input from the user. Both these variables are outside the methods. To enable user input, the required java package has been imported.

The two methods are defined to receive age and display age as mentioned in the question.

The input age is stored in the instance variable age.

void getAge()

   {

       System.out.println("Enter your age");

       age = sc.nextInt();

   }

This variable is used in display() to print the age.

void display()

   {

       System.out.println("Entered age is " + age);

   }

   

All the methods are contained in a single class. Despite this, other methods can only be called through the object of the class which shows that JAVA is purely object oriented language.

public static void main(String args[]) {

       

       Person ob = new Person();

       

       ob.getAge();

       ob.display();

   }

As seen, the instance variable can be used by all methods contained in that particular class. The object of the class is only needed to call the method and not needed to use the instance variables.

4 0
2 years ago
Message queues allow for programs to synchronize their operations as well as transfer data. How much data can be sent in a singl
ser-zykov [4K]

The maximum size of a message queue is 16384 bytes for Linux. For IBM WebSphere MQ. this value is 4 MB.

<h3>What is the message queue?</h3>

The size of the message queue refers to the size (in bytes) that a message may have for a given operative system.

For example, the maximum value for IBM WebSphere MQ has been configured in four megabytes (4 MB).

In this case, when the message is higher than the set size (here 4 MB), then this message is returned.

Learn more about IBM here:

brainly.com/question/896257

6 0
2 years ago
X = 1 if (A = 1 OR B = 1) OR (A = 0 AND B = 1
Gnoma [55]

Answer:

For question a, it simplifies.  If you re-express it in boolean algebra, you get:

(a + b) + (!a + b)

= a + !a + b

= b

So you can simplify that circuit to just:

x = 1 if b = 1

(edit: or rather, x = b)

For question b, let's try it:

(!a!b)(!b + c)

= !a!b + !a!bc

= !a!b(1 + c)

= !a!b

So that one can be simplified to

a = 0 and b = 0

I have no good means of drawing them here, but hopefully the simplification helped!

4 0
2 years ago
Password procedures, information encryption software, and firewalls are examples of measures taken to address:
Gnoma [55]
<span>Password procedures, information encryption software, and firewalls are examples of measures taken to address are all measures taken to safeguard information security and protect users data from being tampered or manipulated by invaders. 

In web, if we leave our information without encryption or if we leave our system without firewall, different types of security threats might arise: such as, information being hacked, manipulated or sent to wrong places. To avoid this information encryption is done. We might also need to firewall our system so that we can avoid unwanted access and invading of our privacy using malwares and other tools. </span>
5 0
3 years ago
I'll give brainlist to right answers
xeze [42]
I think it’s number 1. Check the answer first.
5 0
2 years ago
Other questions:
  • Find the Mechanical Advantage and the maximum separation load for a wedge (length = 6 inches and height = 3 inches) used to spli
    12·1 answer
  • An example of an email client is:<br> A.)Yahoo<br> B.)Gmail<br> C.)Outlook<br> D.)All of the Above
    9·1 answer
  • Hi <br> What exactly does this project want from me?thanks for riding
    5·1 answer
  • Your organization will be handling market trades. You will be required to verify the identify of each customer who is executing
    8·1 answer
  • In an oligopolistic market, consumer choice is?
    12·2 answers
  • Implement the function pairSum that takes as parameters a list of distinct integers and a target value n and prints the indices
    11·1 answer
  • Technology offers a variety of rich opportunities available to teachers and students. According to Inan and Lowther (2010), ther
    6·1 answer
  • A computer with a frequency 2 GHZ and its average cycle per instruction is 2. what is the MIPS of the computer?
    6·1 answer
  • 5. Write the name of the tab, command group, and icon you need to use to access the
    11·2 answers
  • What is the action of extracting data fragments and then reassembling them in order to recover a file?.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!