Skip to content

Commit 1584631

Browse files
committed
Cigar party with test
1 parent 47f34f0 commit 1584631

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

ejviola/cigar_party.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
When squirrels get together for a party, they like to have cigars.
5+
A squirrel party is successful when the number of cigars is between
6+
40 and 60, inclusive. Unless it is the weekend, in which case there
7+
is no upper bound on the number of cigars.
8+
9+
Return True if the party with the given values is successful,
10+
or False otherwise.
11+
"""
12+
13+
def cigar_party(cigars, is_weekend):
14+
try:
15+
if is_weekend == True:
16+
if cigars >= 40:
17+
return True
18+
else:
19+
return False
20+
elif is_weekend == False:
21+
if cigars >= 40 and cigars <=60:
22+
return True
23+
else:
24+
return False
25+
else:
26+
return False
27+
except TypeError:
28+
return False

ejviola/test_cigar_party.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
When squirrels get together for a party, they like to have cigars.
5+
A squirrel party is successful when the number of cigars is between
6+
40 and 60, inclusive. Unless it is the weekend, in which case there
7+
is no upper bound on the number of cigars.
8+
9+
Return True if the party with the given values is successful,
10+
or False otherwise.
11+
"""
12+
13+
14+
# you can change this import to test different versions
15+
from cigar_party import cigar_party
16+
# from cigar_party import cigar_party2 as cigar_party
17+
# from cigar_party import cigar_party3 as cigar_party
18+
19+
20+
def test_1():
21+
assert cigar_party(30, False) is False
22+
23+
24+
def test_2():
25+
assert cigar_party(50, False) is True
26+
27+
28+
def test_3():
29+
assert cigar_party(70, True) is True
30+
31+
32+
def test_4():
33+
assert cigar_party(30, True) is False
34+
35+
36+
def test_5():
37+
assert cigar_party(50, True) is True
38+
39+
40+
def test_6():
41+
assert cigar_party(60, False) is True
42+
43+
44+
def test_7():
45+
assert cigar_party(61, False) is False
46+
47+
48+
def test_8():
49+
assert cigar_party(40, False) is True
50+
51+
52+
def test_9():
53+
assert cigar_party(39, False) is False
54+
55+
56+
def test_10():
57+
assert cigar_party(40, True) is True
58+
59+
60+
def test_11():
61+
assert cigar_party(39, True) is False

0 commit comments

Comments
 (0)