7.1 汽车租赁
代码:
car = input("Hello ,please tell which car you want to lease\n car name:")
print("Let me see if I can find you a " + car)
输出(输入为Subarn):
7-2 餐馆订位
代码:
num = input("Hello ,please tell me how many people have a meal\n number:")
num = int(num)
if num > 8:
print("Sorry there is no spare table")
else:
print("Welcome, we have spare tabels")
输出(输入分别为9和7):
7-3.10的整数倍
代码:
num = input("Hello ,please enter a num and i will tell you"
"whether it is an integer multiple of 10\n num :")
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")
输出(输入分别为100和99)
7-5 电影票
代码:
num = 1
while num >= 0:
num = input("How old are you?\n"
"Enter you age(enter a negative num to quit):")
num = int(num)
if num >= 0 and num < 3:
print("The ticket is free\n")
elif num >= 3 and num <=12:
print("The ticket price is 10$\n")
elif num > 12:
print("The ticket price is 15$\n")
输出(输入分别为6, 3, 2, 15, -1):