write-an-expression-that-continues-to-bid-until-the-user-enters-n.

Page 1

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

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?

İmport 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’. – 2023 / Answer 2:

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)

İmport 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()

https://theboatyacht.com/write-an-expression-that-continues-to-bid-until-the-user-enters-nanswers

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.