PYTHON教程之条件语句if判断
#条件语句if语句
#if conditional_test:
# do something
age=16
if age==16:
print(age)
#if-else语句
#if conditional_test:
# do something
#else:
# do otherthing
if age>20:
print("Age is older than 20!")
else:
print("Age is not older than 20!")
#if-elif-else语句
#if conditional_test:
# do something
#elif:
# do otherthing
#else:
# do anotherthing
if age>20:
print("Age is older than 20!")
elif age>18:
print("Age is older than 18 but younger than 20!")
else:
print("Age is not older than 18!")
运行结果:
"D:\Program Files\python\python.exe" "D:/Program Files/python/example/PYTHON教程之条件语句if判断.py" 16 Age is not older than 20! Age is not older than 18! Process finished with exit code 0


评论