forked from UWPCE-PythonCert/IntroToPython-2014
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodingbat.py
More file actions
31 lines (20 loc) · 721 Bytes
/
Copy pathcodingbat.py
File metadata and controls
31 lines (20 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
"""
Examples from: http://codingbat.com
Put here so we can write unit tests for them ourselves
"""
# Python > Warmup-1 > sleep_in
# The parameter weekday is True if it is a weekday, and the parameter
# vacation is True if we are on vacation.
#
# We sleep in if it is not a weekday or we're on vacation.
# Return True if we sleep in.
def sleep_in(weekday, vacation):
return not weekday or vacation
# We have two monkeys, a and b, and the parameters a_smile and b_smile
# indicate if each is smiling.
# We are in trouble if they are both smiling or if neither of them is
# smiling.
# Return True if we are in trouble.
def monkey_trouble(a_smile, b_smile):
return a_smile is b_smile