Skip to content

Commit 165c91b

Browse files
committed
in progress
1 parent 1c2f1b2 commit 165c91b

File tree

104 files changed

+958
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+958
-225
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@ dmypy.json
128128
# Pyre type checker
129129
.pyre/
130130

131-
#my_exercises
131+
my_exercises

.theia/tasks.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

my_exercises/question_01.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# -*- coding:utf-8 -*-
33

44

5-
6-
def solution(input):
5+
def main():
76
r"""
87
Question 1
98
@@ -15,6 +14,24 @@ def solution(input):
1514
The numbers obtained should be printed in a comma-separated sequence on a single line.
1615
1716
17+
Test:
18+
>>> result = solution(input)
19+
>>> success = True
20+
>>> for x in result:
21+
... if x % 7 != 0 or x % 5 == 0:
22+
... success = False
23+
... break
24+
...
25+
>>> success
26+
True
1827
1928
"""
2029
pass
30+
31+
#### Your code below
32+
33+
#### Your code above
34+
35+
36+
if __name__ == '__main__':
37+
main()

my_exercises/question_02.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# -*- coding:utf-8 -*-
33

44

5-
6-
def solution(input):
5+
def main():
76
r"""
87
Question 2
98
@@ -18,6 +17,19 @@ def solution(input):
1817
40320
1918
2019
20+
Test:
21+
>>> input = 8
22+
>>> result = solution(input)
23+
>>> result
24+
40320
2125
2226
"""
2327
pass
28+
29+
#### Your code below
30+
31+
#### Your code above
32+
33+
34+
if __name__ == '__main__':
35+
main()

my_exercises/question_03.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# -*- coding:utf-8 -*-
33

44

5-
6-
def solution(input):
5+
def main():
76
r"""
87
Question 3
98
@@ -17,6 +16,19 @@ def solution(input):
1716
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}
1817
1918
19+
Test:
20+
>>> input = 8
21+
>>> result = solution(input)
22+
>>> result
23+
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}
2024
2125
"""
2226
pass
27+
28+
#### Your code below
29+
30+
#### Your code above
31+
32+
33+
if __name__ == '__main__':
34+
main()

my_exercises/question_04.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# -*- coding:utf-8 -*-
33

44

5-
6-
def solution(input):
5+
def main():
76
r"""
87
Question 4
98
@@ -18,6 +17,20 @@ def solution(input):
1817
('34', '67', '55', '33', '12', '98')
1918
2019
20+
Test:
21+
>>> input = '34,67,55,33,12,98'
22+
>>> result = solution(input)
23+
>>> result
24+
['34', '67', '55', '33', '12', '98']
25+
('34', '67', '55', '33', '12', '98')
2126
2227
"""
2328
pass
29+
30+
#### Your code below
31+
32+
#### Your code above
33+
34+
35+
if __name__ == '__main__':
36+
main()

my_exercises/question_05.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,43 @@
22
# -*- coding:utf-8 -*-
33

44

5-
6-
def solution(input):
5+
def main():
76
r"""
87
Question 5
98
109
Level 1
1110
1211
Question:
13-
Define a class which has at least two methods:
12+
Define a class named Foo which has at least two methods:
1413
getString: to get a string from console input
1514
printString: to print the string in upper case.
1615
Also please include simple test function to test the class methods.
1716
1817
18+
Test:
19+
>>> from unittest.mock import patch
20+
>>> from io import StringIO
21+
>>> import sys
22+
>>> user_input = ['ABC 123']
23+
>>> with patch('builtins.input', side_effect=user_input):
24+
... obj = Foo()
25+
... obj.getString()
26+
... old_out = sys.stdout
27+
... out = StringIO()
28+
... sys.stdout = out
29+
... obj.printString()
30+
... sys.stdout = old_out
31+
...
32+
>>> out.getvalue().strip()
33+
'ABC 123'
1934
2035
"""
2136
pass
37+
38+
#### Your code below
39+
40+
#### Your code above
41+
42+
43+
if __name__ == '__main__':
44+
main()

my_exercises/question_06.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# -*- coding:utf-8 -*-
33

44

5-
6-
def solution(input):
5+
def main():
76
r"""
87
Question 6
98
@@ -25,3 +24,11 @@ def solution(input):
2524
2625
"""
2726
pass
27+
28+
#### Your code below
29+
30+
#### Your code above
31+
32+
33+
if __name__ == '__main__':
34+
main()

my_exercises/question_07.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# -*- coding:utf-8 -*-
33

44

5-
6-
def solution(input):
5+
def main():
76
r"""
87
Question 7
98
@@ -22,3 +21,11 @@ def solution(input):
2221
2322
"""
2423
pass
24+
25+
#### Your code below
26+
27+
#### Your code above
28+
29+
30+
if __name__ == '__main__':
31+
main()

0 commit comments

Comments
 (0)