只是希望自己能够坚持学习,当个自己的学习笔记,难免有错
用户输入input()和while循环:
1、函数input("提示信息:"): 明确提示信息,使得用户在输入时一目了然
score=input("Your score is:")
print(score)
Your score is:99
99
2、用int()来获取数值输入:
score=input("Your score is:")
score_1=int(score)
print(score_1)
if score_1>90:
print("Your score is "+score+",you are a good student.")
else:
print("Your score is "+score+",Never give up.")
Your score is:87
87
Your score is 87,Never give up.
Your score is:99
99
Your score is 99,you are a good student.
3、while循环:直到条件不满足则跳出循环
让用户选择何时退出: 代码不是很好
score1="If you do not want to see the score,you can input 'Go out'"
score1+="\nYour score is:"
message=""
while message!='Go out':
message=input(score1)
if message!='Go out':
print(message)
If you do not want to see the score,you can input 'Go out'
Your score is:Go out