-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonkey_trouble.py
56 lines (42 loc) · 1.48 KB
/
monkey_trouble.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#CodingBat - Python
#monkey_trouble
#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.
#monkey_trouble(True, True) → True
#monkey_trouble(False, False) → True
#monkey_trouble(True, False) → False
def monkey_trouble(a_smile, b_smile):
return True if a_smile == b_smile else False
print(monkey_trouble(True, True))
print(monkey_trouble(False, False))
print(monkey_trouble(True, False))
# =============================================================================
# def monkey_trouble(a_smile, b_smile):
# if (a_smile and b_smile) or (not a_smile and not b_smile):
# return True
# else:
# return False
# def monkey_trouble(a_smile, b_smile):
# if a_smile and b_smile:
# return True
# if not a_smile and not b_smile:
# return True
# if a_smile and not b_smile:
# return False
# if not a_smile and b_smile:
# return False
# def monkey_trouble(a_smile, b_smile):
# both_smile = a_smile and b_smile
# neither_smile = not (a_smile or b_smile)
# return both_smile or neither_smile
# def monkey_trouble(a_smile, b_smile):
# if a_smile:
# return b_smile
# else:
# return not b_smile
# def monkey_trouble(a_smile, b_smile):
# if b_smile:
# return a_smile
# else:
# return not a_smile