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
The first graphical browser application for using the web was netscape. <br> a. True <br> b. False
Mamont248 [21]
Hello <span>Jcece6710 
</span>

Question: <span>The first graphical browser application for using the web was netscape. True or False


Answer: True

Hope that helps
-Chris</span>
5 0
3 years ago
What can Strings store
horsena [70]
A string is generally considered as a data type and is often implemented as an array data structure of bytes (or words) that stores a sequence of elements, typically characters, using some character encoding. String may also denote more general arrays or other sequence (or list) data types and structures.
5 0
4 years ago
Read 2 more answers
Long-term memory used by the computer:
Fynjy0 [20]
The long term memory used by the computer is called “RAM”
6 0
3 years ago
Read 2 more answers
Which type of storage disk and disk drive can you use in the given situation?
Margarita [4]

Answer:

The answer to this question is DVD and DVD-RW

Explanation:

6 0
3 years ago
Briefly describe the working of computer processing system?
liberstina [14]

Answer:

<em>The Processor</em>

<em>The central processing unit (CPU) guides the computer through the various steps of solving a problem. Data enters the computer through an input unit, is processed by the central processing unit, and is then made available to the user through an output unit.</em>

<em>ExplanationExplanationExplanation:</em>

<em />

5 0
2 years ago
Other questions:
  • To create an individual version of a slide, you would click
    9·1 answer
  • Noticing his reduced performance at work, Dan enrolled himself for training sessions offered by the company and saw his producti
    13·1 answer
  • Which is the correct expansion of the term Internet? 
    9·2 answers
  • Which type of computer is the best? laptop, tablet, or desktop
    15·2 answers
  • Ted has $55.00 in his pocket. Which purchase will he be able to pay for with cash?
    9·2 answers
  • What are youth oraganizations?
    7·1 answer
  • What does a wholesaler do?
    12·1 answer
  • The Company should use BLANK cables to provide Fast connectivity without electrical interference
    6·1 answer
  • Connect 5 LEDs with any random colors. Iteratively, turn ON 1 to 5 LED(s) that will take 5 iterations in total, and in every ite
    6·1 answer
  • Online platforms that allow users to represent themselves via a profile on a web site and provide and receive links to other net
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!