# 3.7 Nested Conditionals 1
# Budget
budget = 1100
# Phone prices
iphone_15_price = 1204
iphone_12_price = 1099
iphone_10_price = 807
# Determine which iPhone you can buy
if budget >= iphone_15_price:
print("You can buy an iPhone 15!")
elif budget >= iphone_12_price:
print("You can buy an iPhone 12!")
elif budget >= iphone_10_price:
print("You can buy an iPhone 10!")
else:
print("You don't have enough money to buy an iPhone.")
# 3.7 Nested Conditionals 2
# Ingredients
has_flour = True
has_sugar = True
has_eggs = True
has_milk = False
has_baking_powder = True
has_vanilla_extract = True
# Baking logic based on available ingredients
if has_flour and has_sugar:
print("You have the basic ingredients.")
if has_eggs:
print("You can make a basic cake batter.")
if has_milk:
print("Great! The cake will be moist.")
else:
print("You don't have milk, the cake might be a bit dry.")
if has_baking_powder:
print("Your cake will rise perfectly.")
else:
print("Without baking powder, the cake might not rise.")
if has_vanilla_extract:
print("The cake will have a nice vanilla flavor.")
else:
print("No vanilla extract, the flavor will be more basic.")
else:
print("You can't bake a cake without eggs.")
else:
print("You don't have enough ingredients to bake a cake.")
# Weather conditions
hot = False
mid = True
cold = True
foggy = False
rainy = True
thunderstormy = False
# Temperature logic based off of the conditions
if not hot and mid:
print("It's decent weather.")
if cold:
print("Cold weather is better weather")
if foggy:
print("Foggy weather is great weather")
else:
print("Unfortunately it's not foggy")
if rainy:
print("Rainy weather is wonderful weather! Be happy.")
else:
print("Unfortunately, it's not rainy")
if thunderstormy:
print("It's thunderstormy!! Thunderstorms are so fun.")
else:
print("Aww, it's not thunderstormy.")
else:
print("Aww it's just meh weather")
else:
print("Bad weather. Bad bad bad bad weather.")