python - 条件语句
生活随笔
收集整理的這篇文章主要介紹了
python - 条件语句
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#-*- coding:utf-8 -*-
# author:jiaxy
# datetime:2018/11/3 11:27
# software: PyCharm Community Edition
# 條件語句
# 根據不同的條件,對不同的情況,做出不同的處理
# if 條件表達式:值為布爾值
# if后面的表達式為True,才會執行if后面的子代碼
score = 80
if score > 95:
print('優秀')
elif 95 > score >= 80:
print('良好')
elif 80 > score >= 60:
print('及格')
else:
print('沒及格')
s = 'PUBG'
if 'B' in s:
print('B is exists')
# 所有為空的數據/為0的數據 ,放在if后面,都會判斷為False
# 所有非空的數據,放在if后面,就會判斷為True
a = ''
if a:
print('WTF!?')
# author:jiaxy
# datetime:2018/11/3 11:27
# software: PyCharm Community Edition
# 條件語句
# 根據不同的條件,對不同的情況,做出不同的處理
# if 條件表達式:值為布爾值
# if后面的表達式為True,才會執行if后面的子代碼
score = 80
if score > 95:
print('優秀')
elif 95 > score >= 80:
print('良好')
elif 80 > score >= 60:
print('及格')
else:
print('沒及格')
s = 'PUBG'
if 'B' in s:
print('B is exists')
# 所有為空的數據/為0的數據 ,放在if后面,都會判斷為False
# 所有非空的數據,放在if后面,就會判斷為True
a = ''
if a:
print('WTF!?')
?
轉載于:https://www.cnblogs.com/gotesting/p/9900251.html
總結
以上是生活随笔為你收集整理的python - 条件语句的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sublime配置随笔提示
- 下一篇: Numpy求均值、中位数、众数的方法