python入门-用户输入

1 input()函数来实现用户输入,程序在等待输入的时候会终止,获取用户的输入后继续

message = input("tell me something,and I will repreat it back to you:")
print(message)

2 使用int来获取数值输入

age = input("How old are you?")

age = int(age)

print(age)

3 求模运算符

number = input("Enter a number,and i'll tell you if it's even or odd:")
number = int(number)

if number % 2 == 0:
    print("
 the number" + str(number) + "is even.")
else:
    print("
 the number" + str(number) + "is odd.")
原文地址:https://www.cnblogs.com/baker95935/p/9277538.html