Processing user input in Python--input function

table of Contents

input () basic use 

Determine whether the input type is a number: isnumeric()


 

input () basic use 

score = input("请输入你的分数:")
print("你的分数是:", score)
print("-------------------")

# 分数判断
if int(score) >= 60:
    print("恭喜你,及格了!")
else:
    print("分数没及格!")

Determine whether the input type is a number: isnumeric()

score = input("请输入你的分数:")
print("你的分数是:", score)
print("-------------------")

# 数字判断
if score.isnumeric():
    if int(score) >= 60:
        print("恭喜你,及格了!")
    else:
        print("分数没及格!")
else:
    print("请输入数字!")

 

Guess you like

Origin blog.csdn.net/qq_40323256/article/details/112163016