7.1 汽车租赁

Python 第七章部分练习

代码:

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

Python 第七章部分练习


7-2 餐馆订位

Python 第七章部分练习

代码:

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

Python 第七章部分练习


7-3.10的整数倍

Python 第七章部分练习

代码:

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)

Python 第七章部分练习



7-5 电影票

Python 第七章部分练习

代码:

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

Python 第七章部分练习




















































































































相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
  • 2021-08-10
  • 2021-10-17
  • 2021-11-13
  • 2021-11-08
  • 2022-02-10
猜你喜欢
  • 2021-06-24
  • 2022-02-25
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
相关资源
相似解决方案