cars = ['audi', 'bmw', 'aubaru', 'toyota'] for car in cars: if car == 'bmw': print(car.upper()) else: print(car.title()) # and or age = 18 age_0 = 20 print(age == 18) print(age > 10) print(age >= 18) print(age < 20) print(age <= 20) print(age > 10 and age_0 < 20) print(age > 10 and age_0 <= 20) print(age > 10 or age_0 < 20) print(age > 10 or age_0 <= 20) # 检查特定值是否包含在列表 request_toppings = ['aa', 'bb', 'cc'] print('检查特定值是否包含在列表:') print('aa' in request_toppings) print('dd' in request_toppings) ages = [1, 2, 3, 4, 5, 6, 7, 8, 9] for age in ages: if age < 3: print(f"{age} is less than 3") elif age < 6: print(f"{age} is more than 3 nut less than 6") else: print(f"{age} id more than 6") available_toppings = ["mushrooms", 'olives', 'green peppers'] request_toppings = ["mushrooms", 'extra cheese'] for request_topping in request_toppings: if request_topping in available_toppings: print("adding " + request_topping + ".") else: print("sorry, we don't have " + request_topping + ".") print("Finished making your pizza.")