打赏

python-条件判断

条件判断

语法:

if 条件:
	条件为真时执行的操作
------------------------------
if 条件:
	条件真执行
else:
	条件为假执行
-----------------------------
if 条件:
	条件真执行
elif 条件:
	条件为真执行
else:
	条件为假执行

示例:

number = 10
if number > 8:
	print("A")
else:
	print("B")

示例二:

score = int(input("成绩>>>"))

if score >= 60 and score < 70:
	print("及格")
elif score >= 70 and score < 80:
	print("中")
elif score >= 80 and score < 90:
	print("良")
elif score >= 90 and score <= 100:
	print("优")
else:
	print("差")
posted @ 2021-10-23 10:54  苍山落暮  阅读(96)  评论(0编辑  收藏  举报