Watch Me Code 1: Do I need more milk?

My family requires a gallon of milk at all times!


In [5]:
milk = float(input("How many gallons of milk do you have? "))
if milk < 1:
    print("Buy more milk!")
else:
    print("You're good for now!")


How many gallons of milk do you have? 0.75
Buy more milk!

Another example.

I only go to the store when I need both diapers and beer!


In [2]:
diapers = input("do you need diapers? ")
beer = input("do you need beer? ")
if diapers == 'yes' and beer=='yes':
    print("You'd better get to the store, ASAP!")
else:
    print("No need to go to the store yet!")


do you need diapers? yes
do you need beer? yes
You'd better get to the store, ASAP!

In [ ]: