Question 1

Everyday, Jack allows himself 30 minutes of nap time. If it is a weekend, Jack allows himself 2 hours (120 minutes) of nap time.

The function nap(time, weekend) takes the number of minutes Jack plans to nap, and a boolean indicating if the day he is napping is on a weekend. If it’s a Saturday or a Sunday, weekend contains True, otherwise it contains False. The function returns a message telling the user if the nap duration is appropriate - being less than or equal to 30 minutes on a weekday, or less than or equal to 2 hours on a weekend. The input argument time will not be negative.

Function Input Argument(s):

There will be 2 arguments:

  1. time (integer)
  2. weekend (boolean)

Function Return Value:

The function should return a string indicating if the duration of the nap on that day is appropriate. If it is, it returns 'Go ahead!', else it returns 'That's too long'.