一.一个简单示例 假设有一个汽车列表,并想将其每辆汽车的名称打印出来.遇到汽车名‘bmw’,以全大写打印:其他汽车名,首字母大写 cars=['audi','bmw','subaru','toyota'] for car in cars: if car == 'bmw': #检查汽车名是否是bmw print(car.upper()) else: print(car.title()) #输出结果: Audi BMW Subaru Toyota 二.条件测试 if 语句的核心都有一个值为True或…
#5.1 major = 'Software Engineering' print("Is major =='Software Engineering'? I predict True.") print(major=='Software Engineering') print("Is major =='Software Engineering'? I predict False.") print(major=='Computer Science') #5.2 pri…