PYTHON TUTORIALS

Conditionals Exercise Answer Key

Answer Key

  1. calories = 500
  2. protein_amt = 12
  3. sugar_amt = 33
  4. organic = True
  5. if calories <= 500 and protein_amt > 5:
       print('This food is healthy')
    else:
       print('This food is unhealthy')
  6. if sugar_amt < 20 or organic = True:
       print('This food is within your diet')
    else:
       print('This food is not within your diet')
  7. if not organic:
       print('This food is not organic')
    elif protein_amt == 10:
       print('This food matches your protein intake levels')
    else:
    print("You shouldn't consume this food because it's not organic and doesn't match your protein intake levels")