7-3 10的整数倍
num = input("Please input a number: ")
num = int(num)
if num % 10 == 0:
print('It is an integer multiple of 10')
else:
print('It is not an integer multiple of 10')
7-6 三个出口
prompt = '\nPlease tell me some ingredients, I will add them to the pizza.'
prompt += "\nEnter 'quit' to end the program. "
ingredient = ""
while ingredient != 'quit':
ingredient = input(prompt)
if ingredient != 'quit':
print('We add ' + ingredient + ' to the pizza.')
prompt = '\nPlease tell me some ingredients, I will add them to the pizza.'
prompt += "\nEnter 'quit' to end the program. "
active = True
while active:
ingredient = input(prompt)
if ingredient != 'quit':
print('We add ' + ingredient + ' to the pizza.')
else:
active = False
prompt = '\nPlease tell me some ingredients, I will add them to the pizza.'
prompt += "\nEnter 'quit' to end the program. "
while True:
ingredient = input(prompt)
if ingredient != 'quit':
print('We add ' + ingredient + ' to the pizza.')
else:
break
7-9 五香烟熏牛肉
sandwich_orders = ['pastrami', 'pastrami', 'pastrami', 'tuna', 'chicken breast']
print('Pastrami has been sold out.')
while 'pastrami' in sandwich_orders:
sandwich_orders.remove('pastrami')
print(sandwich_orders)