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
kolbaska11 [484]
1 year ago
9

Write an expression that continues to bid until the user enters 'n'.

Computers and Technology
1 answer:
alisha [4.7K]1 year ago
7 0

Answer:

1)

Add this while statement to the code:

while(keep_going!='n'):  

#the program keeps asking user to continue bidding until the user enter 'n' to stop.

2)

Here is the code for ACTIVITY 53.3. While loop: Insect growth:

num_insects = int(input())

while num_insects <= 100:

   print(num_insects, end=' ')

   num_insects = num_insects * 2

 

Explanation:

Here is the complete code for 1)

import random

random.seed (5)

keep_going='-'

next_bid = 0

while(keep_going!='n'):

   next_bid = next_bid + random.randint(1, 10)

   print('I\'ll bid $%d!' % (next_bid))

   print('continue bidding?', end='')

   keep_going = input()

Here the the variable keep_going is initialized to a character dash keep_going='-'

The statement keep_going = input() has an input() function which is used to take input from user and this input value entered by user is stored in keep_going variable. while(keep_going!='n'):  is a while loop that keeps iterating until keep_going is not equal to 'n'.    print('continue bidding?', end='')  statement prints the continue bidding? message on the output screen. For example the user enters 'y' when this message appears on screen. So keep_going = 'y' . So the operation in this statement next_bid = next_bid + random.randint(1, 10) is executed in which next_bid is added to some randomly generated integer within the range of 1 to 10 and print('I\'ll bid $%d!' % (next_bid))  prints the result on the screen. Then the user is prompted again to continue biffing. Lets say user enters 'n' this time. So keep_going = 'n'. Now the while loop breaks when user enters 'n' and the program ends.

2)

num_insects = int(input()) #the user is prompted to input an integer

while num_insects <= 100: #the loop keeps iterating until value of num_insects exceeds 100

   print(num_insects, end=' ') #prints the value of num_insects  

   num_insects = num_insects * 2 #the value of num_insects is doubled

For example user enters 8. So

num_insects = 8

Now the while loop checks if this value is less than or equal to 100. This is true because 8 is less than 100. So the body of while loop executes:

   print(num_insects, end=' ') statement prints the value of num_insects

So 8 is printed on the screen.

num_insects = num_insects * 2 statement doubles the value of num_insects So this becomes:

num_insects = 8 * 2

num_insects = 16

Now while loop checks if 16 is less than 100 which is again true so next 16 is printed on the output screen and doubled as:

num_insects = 16 * 2

num_insects = 32

Now while loop checks if 32 is less than 100 which is again true so next 32 is printed on the output screen and doubled as:

num_insects = 32 * 2

num_insects = 64

Now while loop checks if 64 is less than 100 which is again true so next 64 is printed on the output screen and doubled as:

num_insects = 64 * 2

num_insects = 128

Now while loop checks if 128 is less than 100 which is false so the program stops and the output is:

8 16 32 64  

The programs along with their output is attached.

You might be interested in
If the object instance is created in a user program, then the object instance can access both the public and private members of
rewona [7]

Answer:

False

Explanation:

The private member of a class is not accessible by using the Dot notation ,however the private member are those which are not accessible inside the class they are accessible outside the class  .The public member are accessible inside the class so they are accessible by using the dot operator .

<u>Following are the example is given below in C++ Language </u>

#include<iostream>   // header file

using namespace std;  

class Rectangle

{    

   private:  

       double r; // private member  

   public:      

       double  area()  

       {     return 3.14*r*r;  

       }        

};  

int main()  

{    

  Rectangle r1;// creating the object  

   r1.r = 3.5;  

 double t= r1.area(); // calling

cout<<" Area is:"<<t;  

   return 0;  

}  

Output:

compile time error is generated

<u>The correct program to access the private member of class is given below </u>

#include<iostream>   // header file

using namespace std;  

class Rectangle

{    

   private:  

       double r; // private member  

   public:      

       double  area()  

       {    

r1=r;

double t2=3.14*r2*r2;

return(t2); // return the value  

       }        

};  

int main()  

{    

  Rectangle r1;// creating the object  

   r1.r = 1.5;  

 double t= r1.area(); // calling

cout<<" Area is:"<<t;  

   return 0;  

}  

Therefore the given statement is False

5 0
2 years ago
IANA has primarily been responsible with assigning address blocks to five regional internet registries (RIR). A tech needs to re
VikaD [51]

Answer:

The American Registry for Internet Numbers ARIN

Explanation:

The American Registry for Internet Numbers (ARIN) is a not for profit organization that serves as the administrator and distributor of Internet numeric resources such as IP addresses (IPv4 and IPv6) ASN for the United States, Canada, as well as North Atlantic and Caribbean islands

There are four other Regional Internet Registry including APNIC, RIPE NCC, LACNIC and AFRINIC.

6 0
1 year ago
In order to protect your computer from the newest viruses, which of the following should you do after you’ve installed virus sca
GuDViN [60]
Scan it then check it
3 0
1 year ago
In 5–10 sentences, describe the procedure for sending an e-mail message.<br> Please HELP!!!!!
horrorfan [7]
P<span>rocedure for sending an e-mail message:
1. On the email website, click "compose".
2. You can see blank spaces for "to" and "message". CLick "to" to the person you need to send an email to and then "message" for the content of your message.
3. After composing a message, click send.</span>
7 0
1 year ago
The ________ is the agreed-upon interface between all the software that runs on the machine and the hardware that executes it. I
Talja [164]

Answer:

The correct answer to the following question will be "Instruction set architecture".

Explanation:

The Instruction Series Design is a component of the system that is accessible to the compiler and the programmer. It is also the distinction between hardware and software. We will describe in detail the set of instructions used in most of the microprocessors that are used today.

The processor ISA can be represented using 5 categories, these are as follows:

  • The RAM Running Memory.
  • Amount of clear operating names.
  • Location of operands.
  • Operations
  • Size and type of the operand.

Therefore, Instruction set architecture is the right answer.

4 0
1 year ago
Other questions:
  • Frank works for an organization that wishes to install a software program on a single server with multiple users connected. Whic
    8·1 answer
  • Which of the following best defines the term cross-platform application?(A) A program used to coordinate data sharing among mult
    14·2 answers
  • Someone else can drive your car if _____.
    12·2 answers
  • Define a function PyramidVolume with double parameters baseLength, baseWidth, and pyramidHeight, that returns as a double the vo
    7·2 answers
  • Eric is working on a computer that has a device driver error. Eric can find the name of the device driver however the actual dev
    9·2 answers
  • Universal Containers needs a field on the Account to track how many Opportunities are closing within the next 30 days. What can
    9·1 answer
  • Which method allows a computer to react accordingly when it requests data from a server and the server takes too long to respond
    5·1 answer
  • Which of the following is not true about VOIP?
    9·1 answer
  • Explain why Windows and Linux implements multiple locking mechanisms. Describe the circumstances under which they use spinlocks,
    13·1 answer
  • Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!