answer.
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
Cloud [144]
2 years ago
7

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

Computers and Technology
1 answer:
fiasKO [112]2 years ago
7 0

Answer:

The complete program is as follows:

keepGoing = True

attempts = 0

correct = 2

while keepGoing:

    guess = input("Guess an integer from 1 to 10: ")

    guess = int(guess)

    attempts = attempts + 1

    if guess == correct:

         print("You were correct!")

         keepGoing = False

    elif guess < correct:

         print("Guess higher.")

    else:

         print("Guess lower. ")

Explanation:

This line initializes keepGoing to true

keepGoing = True

This initializes number of attempts to 0

attempts = 0

This initializes the correct guess to 2 (you can also use any number)

correct = 2

The following iteration is repeated until the number is guessed correctly

while keepGoing:

    guess = input("Guess an integer from 1 to 10: ")

    guess = int(guess)

    attempts = attempts + 1

    if guess == correct:

         print("You were correct!")

If user guess is correct, keepGoing is set to False

         keepGoing = False

    elif guess < correct:

         print("Guess higher.")

    else:

         print("Guess lower. ")

You might be interested in
Given two integers as user inputs that represent the number of drinks to buy and the number of bottles to restock, create a Vend
ivann1987 [24]

Answer:

In C++:

#include <iostream>

using namespace std;

class VendingMachine {

 public:

   int initial = 20;};

int main() {

 VendingMachine myMachine;

   int purchase, restock;

   cout<<"Purchase: ";  cin>>purchase;

   cout<<"Restock: ";  cin>>restock;

   myMachine.initial-=(purchase-restock);

   cout << "Inventory: "<<myMachine.initial<<" bottles";  

   return 0;}

Explanation:

This question is incomplete, as the original source file is not given; so, I write another from scratch.

This creates the VendingMachine class

class VendingMachine {

This represents the access specifier

 public:

This initializes the inventory to 20

   int initial = 20;};

The main begins here

int main() {

This creates the object of the VendingMachine class

 VendingMachine myMachine;

This declares the purchase and the restock

   int purchase, restock;

This gets input for purchase

   cout<<"Purchase: ";  cin>>purchase;

This gets input for restock

   cout<<"Restock: ";  cin>>restock;

This calculates the new inventory

   myMachine.initial-=(purchase-restock);

This prints the new inventory

   cout << "Inventory: "<<myMachine.initial<<" bottles";  

   return 0;}

8 0
2 years ago
The ________ program displays graphics and loading screens during the boot process.
Minchanka [31]
Booting would be complete if the normal, runtime environment has been achieved. A boot loader is a program that loads operating system for the computer after the completion of power on tests. The boot manager is a program that displays graphics and loading screens during the boot process.
3 0
2 years ago
If byte stuffing is used to transmit Data, what is the byte sequence of the frame (including framing characters)? Format answer
Lerok [7]

Answer:

Correct Answers: 01h 79h 1Bh 78h 78h 1Bh 7Ah 04

Explanation:

Solution is attached below

4 0
2 years ago
Susie works for an architectural firm and the partners have always drawn the plans for projects by hand. Though Susie learned ho
lidiya [134]

Answer:

The correct answer to the following question will be CAD.

Explanation:

CAD - It stands for Computer-aided Design. CAD is a software used for creating some 3D designs, creative drawing or some technical illustrations and is basically used by the engineers and artists.

Many projects based on electronic can be designed with the help of this software, electronic parts like circuit boards, etc.

Various types of CAD are as follows :

  • 2D (Two dimensional)
  • 3D (Three dimensional)
  • 3D wire frame
  • Solid modeling

This enables efficiency in design's quality, also increase in engineer and artist's productivity. So, many of the computer programs should recommend the Computer-aided design software to there project partners for some 3D and effective look on their project.

3 0
2 years ago
Define a function ComputeGasVolume that returns the volume of a gas given parameters pressure, temperature, and moles. Use the g
lara [203]

Answer:

double ComputeGasVolume(double pressure, double temperature, double moles){

   double volume = moles*GAS_CONST*temperature/pressure;

    return volume;        

}

Explanation:

You may insert this function just before your main function.

Create a function called ComputeGasVolume that takes three parameters, pressure, temperature, and moles

Using the given formula, PV = nRT, calculate the volume (V = nRT/P), and return it.

6 0
2 years ago
Other questions:
  • What are the possible consequences if you fail to identify system requirements correctly and completely?
    9·1 answer
  • Letitia is in high school. She wants to go to medical school in Kentucky and then become a pediatric surgeon to help children. W
    5·2 answers
  • The main problem with radio transmission is which of the following? Select one: a. Radio waves cannot travel through walls. b. W
    9·2 answers
  • The effectiveness of a(n) _____ process is essential to ensure the success of a data warehouse. Select one: a. visual basic b. e
    15·2 answers
  • covers a wide variety of applications such as web and computer-based training (CBT), and social networks. a. E-learning b. Model
    10·1 answer
  • Refer to the exhibit. The PC is connected to the console port of the switch. All the other connections are made through FastEthe
    6·1 answer
  • ___________is used for drawing 3D objects in the field of Science and Engineering.
    12·2 answers
  • Write a statement to create a new Thing object snack that has the name "potato chip". Write the statement below.
    5·1 answer
  • In the graph shown here, by what percentage are the number of people in computer occupations in general projected to increase?
    10·2 answers
  • A customer opened a file attachment, and now her PC is infected with ransomware. She's unable to open any of her files. Which ac
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!