简简单单学Python

简简单单学Python,第1张

只是希望自己能够坚持学习,当个自己的学习笔记,难免有错

用户输入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

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/922750.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-16
下一篇2022-05-16

发表评论

登录后才能评论

评论列表(0条)

    保存