7-3
num = int(input('please input a number:'))
if num % 10 == 0:
print('This number is an integer multiple of 10.')
else:
print('This number is not an integer multiple of 10.')
7-5
age = input('Please input your age:(input "q" to quit)')
while age != 'q':
age = int(age)
if age < 3:
print('You are free of chareg.')
elif age < 12:
print('The price of your ticket is 10 dollars.')
else:
print('The price of your ticket is 15 dollars.')
age = input('Please input your age:(input "q" to quit)')
7-8
sandwich_orders = ['pastrami', 'ham', 'chicken', 'pastrami', 'cheese', 'pastrami']
finished_sandwiches = []
while sandwich_orders:
print('I made your tuna sandwich.')
finished_sandwiches.append(sandwich_orders.pop())
print(sandwich_orders)
print(finished_sandwiches)

7-9:
sandwich_orders = ['pastrami', 'ham', 'chicken', 'pastrami', 'cheese', 'pastrami']
finished_sandwiches = []
print('pastrami was sold out')
while 'pastrami' in sandwich_orders:
sandwich_orders.remove('pastrami')
while sandwich_orders:
print('I made your tuna sandwich.')
finished_sandwiches.append(sandwich_orders.pop())
print(finished_sandwiches)
output:
8-2
def favorite_book(title):
print('One of my favorite book is ' + title + '.')
favorite_book('Alice in Wonderland')
output:
8-5
def describec_city(city, country = 'China'):
print(city + ' is in ' + country + '.')
describec_city('Beijing')
describec_city(city = 'Guangzhou')
describec_city('London', country = 'England')
output:
8-12
def sandwich(*toppings):
print('The types of sandwich include:')
for topping in toppings:
print(topping)
sandwich('pastrami', 'ham', 'chicken')
output: