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
What is output? c = 1 sum = 0 while (c &lt; 10): c = c + 3 sum = sum + c print (sum)
Valentin [98]

Answer:

21

Explanation:

The values of c that make it into the loop are 1, 4, 7.

The values that are added to sum are 3 higher, i.e., 4,7 and 10.

The sum of those is 21.

p.s. why did you not run the program yourself?

3 0
3 years ago
Yo who do u add a pic on here
Juliette [100K]
Go to the me colum when you first open the app
8 0
3 years ago
Laurel, the manager of a software company, assumes that the male employees in his organization are more creative and innovative
grandymaker [24]

Answer:

Sterotyping

Explanation:

A stereotype is an over-generalized perception or view about a particular category of individuals or group. It is a belief that people might have concerning each and every person of a particular group. The type of expectation can differ from people to people; it can be, for instance, a belief or perception about a particular group's personality, preferences, or ability.

5 0
3 years ago
In the game Singularity, broken objects can be restored to their original condition by reversing time. This is an example of whi
Zolol [24]

Solution:

In the game Singularity, broken objects can be restored to their original condition by reversing time. This is an example of which time element of player adjustment.

Thus the required answer is player adjusted.

6 0
3 years ago
Read 2 more answers
What country is associated with the tor relay using the ip address 104. 244. 74. 97?.
Lelu [443]

Answer:

104.28.63.45 is an IP address located in Santos, Sao Paulo.

Explanation:

3 0
2 years ago
Other questions:
  • How do you ask someone for help?
    6·1 answer
  • A ____ is a circuit board that contains most of a server.
    8·1 answer
  • You notice that somehow you have duplicate records for some of your clients in your database. What should you do?
    13·2 answers
  • Adele’s mother owns a Daycare and she wants to learn all about this business, to help her mom and own it one day. Which CTSO sho
    9·1 answer
  • While accessing mail through the mail command interface, a user sees 5 new messages in his mailbox. Since the second message app
    13·1 answer
  • 3.2 lesson practice edhesive ​
    6·1 answer
  • A user purchased a new smart home device with embedded software and connected the device to a home network. The user then regist
    5·1 answer
  • What is a characteristic of tasks in Outlook?
    10·2 answers
  • Which era marked a switch from agricultural practices to industrial practices?
    6·1 answer
  • A(n) ________ is often developed by identifying a form or report that a user needs on a regular basis.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!