Skip to content

Commit dcc81a9

Browse files
authored
Logic
1 parent dae4636 commit dcc81a9

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

PyPrac5.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
# # When squirrels get together for a party, they like to have cigars. A squirrel party is successful when the number of cigars is between 40 and 60, inclusive. Unless it is the weekend, in which case there is no upper bound on the number of cigars. Return True if the party with the given values is successful, or False otherwise.
5+
#
6+
#
7+
8+
# In[2]:
9+
10+
11+
def cigar_party(cigars, is_weekend):
12+
if is_weekend:
13+
return cigars>=40
14+
else:
15+
return cigars>=40 and cigars<=60
16+
17+
cigar_party(30, False)
18+
19+
20+
# # #Given 2 ints, a and b, return their sum. However, sums in the range 10..19 inclusive, are forbidden, so in that case just return 20.
21+
#
22+
#
23+
24+
# In[3]:
25+
26+
27+
def sorta_sum(a, b):
28+
return 20 if a+b in range(10,20) else a+b
29+
sorta_sum(9, 4)
30+
31+
32+
# # The squirrels in Palo Alto spend most of the day playing. In particular, they play if the temperature is between 60 and 90 (inclusive). Unless it is summer, then the upper limit is 100 instead of 90. Given an int temperature and a boolean is_summer, return True if the squirrels play and False otherwise.
33+
34+
# In[6]:
35+
36+
37+
def squirrel_play(temp, is_summer):
38+
if 60 <= temp <= 90:
39+
return True
40+
elif is_summer and 60<=temp<=100:
41+
return True
42+
return False
43+
squirrel_play(95, False)
44+
45+
46+
# In[ ]:
47+
48+
49+
50+

0 commit comments

Comments
 (0)