Solutions

Ex 1. Enough money?

money = input("How much money do you have?") money = int(money) apples = input("How many apples do you want to buy?") apples = int(apples) cost = apples * 2 if cost > money: print("You don't have enough money") else: print("You have enough money")

Ex 2. Apples and Oranges

money = 20 choice = input("Do you prefer apples or oranges?") if choice == "apples": price = 2 fruits = input("How many apples do you want to buy?") else: price = 3 fruits = input("How many oranges do you want to buy?") cost = price * int(fruits) if cost > money: print("You don't have enough money") else: print("You have enough money")

Ex 3. Rainy Day

temperature = input("What is the temperature?") temperature = int(temperature) raining = input("Is it raining? (yes / no)") if temperature > 30 and raining == 'yes': print("It is a hot and rainy day") elif temperature > 30 and raining == 'no': print("It is a hot and dry day") elif temperature <= 30 and raining == 'yes': print("It is a cold and rainy day") elif temperature <= 30 and raining == 'no': print("It is a cold and dry day") else: print("Invalid answers")