python

函数input()的工作原理

2018-11-02  本文已影响8人  庵下桃花仙
# 7-1
need_car = input("请问,您想租什么车?")
print("让我看看是否能找到" + need_car + "。")

# 7-2
people_num = input("请问有多少人就餐: ")
prople_num = int(people_num)

if prople_num > 8:
    print("抱歉,没有空位了!")
else:
    print("好的,还有空位!")

# 7-3
prompt = "Enter a numberm, and I will tell you if it is an integer multiple of 10."
prompt += "\nnumber: "
number = input(prompt)
number = int(number)

if number % 10 == 0:
    print("\nThe number" + str(number) + " is an integer multiple of 10.")
else:
    print("\nThe number " + str(number) + " is not an integer multiple of 10")
请问,您想租什么车?特斯拉
让我看看是否能找到特斯拉。
请问有多少人就餐: 8
好的,还有空位!
Enter a numberm, and I will tell you if it is an integer multiple of 10.
number: 99

The number 99 is not an integer multiple of 10
上一篇下一篇

猜你喜欢

热点阅读