Skip to content

Commit a992032

Browse files
committed
Warmup-1 solutions
1 parent 8e7b820 commit a992032

File tree

12 files changed

+65
-0
lines changed

12 files changed

+65
-0
lines changed

Warmup_1/diff21.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def diff21(n):
2+
if n > 21 :
3+
return 2*(n-21)
4+
else :
5+
return 21-n

Warmup_1/front3.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def front3(str):
2+
if len(str) <3 :
3+
front =str
4+
else:
5+
front = str[0:3]
6+
return front + front +front

Warmup_1/front_back.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def front_back(str):
2+
if len(str)<=1:
3+
return str
4+
else :
5+
first= str[0]
6+
last= str[len(str)-1]
7+
return last+ str[1:len(str)-1] + first

Warmup_1/makes10.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def makes10(a, b):
2+
if (a==10 or b==10) or a+b==10 :
3+
return True
4+
else :
5+
return False

Warmup_1/missing_char.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def missing_char(str, n):
2+
if n==0 :
3+
return str[1:]
4+
elif n==len(str) :
5+
return str[:-1]
6+
else :
7+
return str[0:n]+str[n+1:]

Warmup_1/monkey_trouble.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def monkey_trouble(a_smile, b_smile):
2+
if (a_smile and b_smile) or (not a_smile and not b_smile) :
3+
return True
4+
else:
5+
return False

Warmup_1/near_hundred.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def near_hundred(n):
2+
temp1 = abs(100-n)
3+
temp2= abs(200-n)
4+
return temp1<=10 or temp2 <=10

Warmup_1/not_string.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def not_string(str):
2+
temp = str[:3]
3+
if temp == 'not':
4+
return str
5+
else:
6+
return "not "+str

Warmup_1/parrot_trouble.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def parrot_trouble(talking, hour):
2+
if talking and ((hour <7) or (hour >20)) :
3+
return True
4+
else :
5+
return False

Warmup_1/pos_negative.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def pos_neg(a, b, negative):
2+
return (((a>0 and b<0) or (a<0 and b>0)) and not negative) or ((a<0 and b<0) and negative)

0 commit comments

Comments
 (0)