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

Page 1

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’ comments:

• 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()

https://numberoneboats.com/write-an-expression-that-continuesto-bid-until-the-user-enters-n

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.