Python入门习题大全——索引
编写一个程序,询问用户有多少人就餐。如果超过 8 人,就打印一条消息,指出没有空桌;否则指出有空桌。
# 餐馆订位
a = input("How many people?\n")
a = int(a)
if a > 8:
print("No")
else:
print("Yes")
输出为:
(输入9)
How many people?
9
No
(输入7)
How many people?
7
Yes
编写一个程序,询问用户有多少人就餐。如果超过 8 人,就打印一条消息,指出没有空桌;否则指出有空桌。
# 餐馆订位
a = input("How many people?\n")
a = int(a)
if a > 8:
print("No")
else:
print("Yes")
输出为:
(输入9)
How many people?
9
No
(输入7)
How many people?
7
Yes