Free: Write an expression that continues to bid until the user enters ‘n’.

Write an expression that continues to bid until the user enters ‘n’.2023 answers Welcome to text. Various questions in schools and events confuse people. ? People often look for answers to questions they can’t solve on the internet. This is exactly where we step in.

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

Write an expression that continues to bid until the user enters ‘n’. Sample output with inputs: ‘y’ ‘y’ ‘n’ I’ll bid $7! Continue bidding? I’ll bid $15! Continue bidding? I’ll bid $23! Continue bidding?

  • 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 ${}!’.format(next_bid))
  • print(‘Continue bidding?’, end=’ ‘)
  • keep_going = input()

Write an expression that continues to bid until the user enters ‘n’. Answer 2:

1) Add this while statement to the code:

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

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

Write An Expression That Continues To Bid Until The User Enters ‘N’. Java

Write An Expression That Continues To Bid Until The User Enters ‘N’. Java, below. All answers:

  • 4.3.2: Bidding example.
  • import java.util.Scanner;
  • public class AutoBidder {
  • public static void main (String [] args) {
  • Scanner scnr = new Scanner(System.in);
  • char keepGoing;
  • int nextBid;
  • nextBid = 0;
  • keepGoing = ‘y’;
  • while (keepGoing != ‘n’) {
  • nextBid = nextBid + 3;
  • System.out.println(“I’ll bid $” + nextBid + “!”);
  • System.out.print(“Continue bidding? (y/n) “);
  • keepGoing = scnr.next().charAt(0);
  • }
  • System.out.println(“”);
  • }
  • }

Write An Expression That Continues To Bid Until The User Enters ‘N’. Python

Write An Expression That Continues To Bid Until The User Enters ‘N’. Pyhton answers below.

In Python:

  • Write an expression that continues to bid until the user enters ‘n’.
  • Sample output with inputs: ‘y’ ‘y’ ‘n’
  • I’ll bid $7!
  • Continue bidding? I’ll bid $15!
  • Continue bidding? I’ll bid $23!
  • Continue bidding?
  • import random
  • random.seed(5)
  • keep_going = ‘-‘
  • next_bid = 0
  • while keep_going == ‘y’:
  • next_bid = next_bid + random.randint(1, 10)
  • print(‘I\’ll bid ${}!’.format(next_bid))
  • print(‘Continue bidding?’, end=’ ‘)
  • keep_going = input()

I keep getting an error code stating that my code produced no output?

Write an expression that continues to bid until the user enters ‘n’. is over. We usually post boats and yachts on our site. But we also answer difficult questions for you, our dear students. You can support us by leaving a thank you comment.

You may also like these boats and yachts for sale:

4.8/5 - (82 votes)

7 thoughts on “Free: Write an expression that continues to bid until the user enters ‘n’.”

  1. Answer from write an expression that continues to bid until the user enters n. Thanks ?❤️ Usa Student!.

    Reply
Leave a Comment

1