Skip to content

Commit af120e7

Browse files
committed
Solving 1- double exercises
1 parent dfc29a8 commit af120e7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Sprint5/double.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def double(n):
2+
return n*2
3+
num = double("22")
4+
print(num)
5+
6+
#my prediction is that it would return 2222. As python will treat 22 as a string being a strongly typed language.
7+
#if it was javascript * operator would have forced numeric converion and 22 string would have become 22 int and 44 would
8+
#have been returned
9+
# when I run the file it returns 2222 as expected.
10+
11+
# 2nd exercise- original function :
12+
def double(number):
13+
return number * 3
14+
15+
print(double(10)) # returns "30"
16+
17+
#so we either change the name of the function to triple or multiply number with 2 rather than 3
18+
def triple(number):
19+
return number * 3
20+
21+
print(triple(10)) # returns "30"

0 commit comments

Comments
 (0)