7-1
car = input('Please tell me which kind of car you want:\n')
print('Let me see if I can find you a ' + car + ' .')
7-2
seats = int(input('How many seats do you want?\n'))
if seats > 8:
print('Sorry, but there are not enough seats.')
else:
print('Please come in, there are enough seats.')
7-3
num = int(input('Please enter an integer:\n'))
if num % 10 == 0:
print(str(num) + ' is a multiple of 10.')
else:
print(str(num) + ' is not a multiple of 10.')
7-4
prompt = 'Please tell me the ingredients of pizza that you like:\n'
prompt += "Enter 'quit' to end the program.\n"
while True:
message = input(prompt)
if message == 'quit':
break
else:
print('We will add this ingredient into pizzas.')
7-5
prompt = 'Please tell me your age, and I will show you the price:\n'
prompt += "Enter 'quit' to end the program.\n"
while True:
age = input(prompt)
if age == 'quit':
break
else:
age = int(age)
if age < 3:
print('Your ticket is free.')
elif age >= 3 and age <= 12:
print('Your ticket is 10 dollars.')
else:
print('Your ticket is 15 dollars.')
7-7
while True:
print('This will not stop.')
7-8
sandwich_orders = ['pork sandwich','beef sandwich','chicken sandwich']
finished_sandwich = []
while sandwich_orders:
sand = sandwich_orders.pop()
print('I made your ' + sand + ' .')
finished_sandwich.append(sand)
print('All the sandwiches are finished:')
for sand in finished_sandwich:
print(sand)
7-10
survey = {}
while True:
name = input('What\'s your name?\n')
prompt = 'If you could travel around the world, '
prompt += 'where would you go?\n'
place = input(prompt)
survey[name] = place
re = input('Would you like to let others answer this question?(y/n)\n')
if re == 'n':
break
for name,place in survey.items():
print(name + " wants to travel to " + place + ' .')