7-1
编写一个程序,询问用户要租赁什么样的汽车,并打印一条消息,如“Let me see if I can find you a Subaru”。
car = input('Which car do you like?')
print('Let me see if I can find you a ' + car + '.')
7-2
编写一个程序,询问用户有多少人用餐。如果超过8人,就打印一条消息,指出没有空桌;否则指出有空桌。
number = int(input('How many people are going to have lunch?'))
if number > 8:
print('There is no table.')
else:
print('There are empty tables.')
7-3
让用户输入一个数字,并指出这个数字是否是10的整数倍。
number = int(input('Please input a number:'))
if number % 10 == 0:
print('It is divisible by 10.')
else:
print('It is not divisible by 10.')
7-4
编写一个循环,提示用户输入一系列的比萨配料,并在用户输入’quit’ 时结束循环。每当用户输入一种配料后,都打印一条消息,说我们会在比萨
中添加这