Python 第七章部分练习

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):





















































































































评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值