1. 基本用法
# _*_ coding:utf8 _*_
# 条件测试
cars = ['ad', 'bm', 'bc', 'fll']
for car in cars:
if car == 'ad':
print(car.upper())
else:
print(car.title())
# 赋值
car = 'ad'
# 判断 为真输出True 为假输出False
print(car == 'ad')
car = 'bm'
print(car == 'bb')
car = 'BM'
print(car == 'bm')
print(car.lower() == 'bm')
if car != 'BM':
print("this is my option")
# 比较数字
number = 14
print(number >= 15)
# 多条件检查 and or
age_0 = 19
age_1 = 20
# false
print(age_0 >= 20 and age_1 >= 20)
# true
print(age_0 >= 20 or age_1 >= 20)
# 检查特定值是否包含在列表中 使用关键字 in
students = ['zhangqi','qiyongshuai','chengjian','renhengyao']
print('zhangqi' in students)
print('zhanglu' in students)
# 检查特定值是否不包含在列表中 关键字为 not in
banned_users = ['lb','dp','tym','mhr']
user = 'zq'
if user not in banned_users:
print("hello")