Session Ready
Exercise

Control flow

Conditional statements work similarly in R and Python. This is a basic skeleton of if-else statements in Python:

x = 1

if x > 0:
    print('Positive')
elif x < 0:
    print('Negative')
else:
    print('Zero!')

In the United States, the Center of Disease Control defines 'binge' drinking when men consume 5 or more drinks or women consume 4 or more drinks in about 2 hours. In this exercise, you will write a bunch of conditional statements to determine the status of a person who had 5 drinks.

Instructions
100 XP
  • Assign 5 to a variable: num_drinks.
  • Write an if statement that prints 'error' if num_drinks is less than 0.
  • Write an elif statement that prints 'non-binge' if num_drinks is less than or equal to 4.
  • Write an else statement that prints 'binge'.