NP37 游乐园的门票

思路:

step1:对不同情况分别判断并输出即可;

代码如下:

while True:
    try:
        print("Please tell me your height!\nEnter 'quit' to end the program.")
        n = input()
        if n == 'quit':
            break
        else:
            n = float(n)
            if n < 1.0:
                print('Your admission cost is 0 yuan.')
            elif 1.0 <= n <= 1.2:
                print('Your admission cost is 80 yuan.')
            elif n > 1.2:
                print('Your admission cost is 150 yuan.')
    except:
        break