python编程从入门到实践第七章习题

时间:2021-05-17 19:21:26

#7-1 输入输出
message = input( "What car do you want?")
print( "Let me see if i can find you a ", message)
#7-2 判断是否有空桌
number = input( "How many people are having the dinner?")
number = int( number)
if number > 8 :
    print( "There is no empty desk")
else :
    print( "There is still some empty desk")

#7-3 判断输入是否为10的整数倍
number = input("Please inpyt a number")
number = int(number)
if not number%10 :
    print( "是10的整数倍")
else :
    print("不是10的整数倍")

#7-4 披萨配料
add = []
while True :
    message = input("Please input something that you want:")
    if message == "QUIT" :
        break
    add.append(message)
    print( "We have added " , message )

#7-5 电影票
while True:
    age = input( "Please input your age:")
    age = int(age)
    if ( age < 3 ) :
        print( "You are free for it!")
    elif ( age <= 12 ):
        print( "Your price for it is $10")
    else :
        print( "Your price for it is $15")