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
Two electronics technicians are measuring electrical quantities in circuits. Technician A says that copper, glass, porcelain, an
OleMash [197]

The correct answer is A. Only technician B is correct because I don't believe carbon is form of resistors.


8 0
3 years ago
Read 2 more answers
5. The coordinates of triangle ABC are A(-7, 3), B(3, -7) and C(8. 8)
kati45 [8]

Answer:

b

Explanation:

6 0
3 years ago
Read 2 more answers
Piers wants to take a course on XML. He is a certified web designer,but he has not used XML before. How can he use XML to improv
Agata [3.3K]

Answer:

It will bring more verstality in his website. He will be able to define tags.

Explanation:

XML allows to define your own tags. You can bring semantics into your website which make data browsing easier.

3 0
3 years ago
What is spread sheet software?​
melamori03 [73]

Answer:

The answer to this question is given in the explanation section.

Explanation:

This is a type of software which show us data in tabular form. These software can easily store, analyze and organize data.

They are divided in rows and columns. They are mainly used for accounting and book keeping.

The commonly used spread sheet software in the market are MS Excel by Microsoft, Calc by libre office.

3 0
3 years ago
Beth’s multimedia business specializes in sound integration and editing. A New project requires video editing and the creation o
ANEK [815]

Answer:

A. Adobe illustrator

Explanation:

4 0
3 years ago
Other questions:
  • Consider the following class definitions.
    10·1 answer
  • A wireless (radio) transmission of data can only travel a short distance.<br><br> True or false?
    9·1 answer
  • When seeking information on the internet about a variety of subjects, the most useful place to look would be
    8·2 answers
  • You can apply several different worksheet themes from which tab?
    11·2 answers
  • My mac book airs touch pad stopped working and i can't click. what do i do?
    5·2 answers
  • application that will perform a lot of overwrites and deletes of data and requires the latest information to be available anytim
    8·1 answer
  • Direct Mapped Cache. Memory is byte addressable. Fill in the missing fields based upon the properties of a direct-mapped cache.
    6·1 answer
  • What does "CPU" stand for?
    15·2 answers
  • The _____ method randomly rearranges the items in the list provided in the parentheses.
    5·2 answers
  • 1.1 give five (5) reasons why modeling is an important part of system analysis and design
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!