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
Keith_Richards [23]
3 years ago
7

You wrote a program to allow the user to guess a number. Complete the code to give the user feedback.

Computers and Technology
2 answers:
geniusboy [140]3 years ago
8 0

Answer:

The complete program is:

import random

keepGoing = True

num = random.randint(0,9)  

guess = int(input("Your guess: "))

while keepGoing == True:

   if num == guess:

       print("You were correct!")

       keepGoing = False

   else:

       print("You were wrong.")

       guess = int(input("Your guess: "))

       keepGoing = True

Explanation:

<em>To answer this program, I let the computer generate a random number, then let the user make a guess.</em>

<em></em>

This imports the random module

import random

This initializes a Boolean variable keepGoing to True

keepGoing = True

Generate a random number

num = random.randint(0,9)  

Let the user take a guess

guess = int(input("Your guess: "))

The loop is repeated until the user guesses right

while keepGoing == True:

Compare user input to the random number

   if num == guess:

If they are the same, then the user guessed right

       print("You were correct!")

Update keepGoing to False

       keepGoing = False

If otherwise,

   else:

then the user guessed wrong

       print("You were wrong.")

Prompt the user for another number

       guess = int(input("Your guess: "))

Update keepGoing to True

       keepGoing = True

alina1380 [7]3 years ago
3 0

Answer:

Complete the code below, which is an alternative way to give the user the same hints.

    if guess == correct:

       # Tell the user the guess was correct.

       print("You were correct!")

       keepGoing = False

   

elif guess < correct

:

       print("Guess higher.")

   

else

:

       print("Guess lower.")

Explanation:

Edge 2021

You might be interested in
Prensentation software allows user to?
Grace [21]

Answer:

package used to show information, normally in the form of a slide show. It mostly includes three major functions: an editor that allows text to be inserted and formatted, a method for inserting and manipulating graphic images and a slide-show system to display the content.

7 0
3 years ago
The difference between tool bar and status bar​
Snowcat [4.5K]

Answer:

A toolbar offers easier access to tasks typically conducted within the application whereas in the status bar it is displayed at the lower side of the web browser screens and other application windows.

Explanation:

8 0
2 years ago
What are some consequences of internet addiction​
fenix001 [56]

Answer:

<em>1</em><em>. </em><em>week</em><em> </em><em>eyesight</em>

<em>2</em><em>. </em><em> </em><em>weak</em><em> </em><em>brain</em><em> </em><em>power</em>

<em>3</em><em>. </em><em>loss</em><em> </em><em>of</em><em> </em><em>concentra</em><em>tion</em><em>.</em><em>.</em><em>.</em>

<em>hope</em><em> </em><em>it</em><em> </em><em>helps</em><em> </em><em>u</em>

4 0
3 years ago
Three reasons why users attach speakers to their computers.
ZanzabumX [31]

Answer:

Iv'e answered this question 2 times already lol. The purpose of speakers is to produce audio output that can be heard by the listener. Speakers are transducers that convert electromagnetic waves into sound waves. The speakers receive audio input from a device such as a computer or an audio receiver.

Explanation: I hope this helps!

8 0
3 years ago
What type of lens was used to take this picture?
Leona [35]

Fish-eye because this is how you would see through a "fish eye" point of view in a rounded tank that is commonly used.

May I please have brainliest

4 0
4 years ago
Other questions:
  • There is no need to schedule video calls ahead of time; they can be used the same way as
    6·1 answer
  • Which command displays the status of the ipsec installation?
    7·1 answer
  • How can our perceptions help us to choose the channel for our message?
    5·1 answer
  • Why should programmers use a Post Mortem Review?
    15·1 answer
  • Which is true of effective passwords?
    5·1 answer
  • a hacker who plants a rogue wireless access point on a network in order to sniff the traffic on the wired network from outside t
    12·1 answer
  • Who still plays old Nintendo 64 games?
    6·2 answers
  • To print photographs in color.​
    7·1 answer
  • Explain about third generation of computer​
    5·1 answer
  • What can a human till do better and fater than any Machine Learning (ML) olution?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!