Skip to content

Commit ec3675b

Browse files
committed
Merge branch 'master' of https://github.com/Khrisefzm/master-python-programming-exercises into bug-exercise-23
2 parents 308f000 + 02c96dc commit ec3675b

File tree

171 files changed

+1837
-400
lines changed

Some content is hidden

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

171 files changed

+1837
-400
lines changed
+25

exercises/021-square_root/README.md

+25

exercises/021-square_root/app.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Your code here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Your code here
2+
import math
3+
4+
def square_root(number):
5+
result = round(math.sqrt(number), 2)
6+
return result
7+
8+
9+
print(square_root(50))

exercises/021-square_root/test.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import io, sys, os, re, pytest
2+
import app
3+
4+
@pytest.mark.it('You should create a function named square_root')
5+
def test_square_root_exists(app):
6+
try:
7+
from app import square_root
8+
assert square_root
9+
except AttributeError:
10+
raise AttributeError("The function 'square_root' should exist on app.py")
11+
12+
@pytest.mark.it('The function must return something')
13+
def test_function_return(capsys, app):
14+
assert app.square_root(25) != None
15+
16+
@pytest.mark.it('The function must return a float number')
17+
def test_function_return_type(capsys, app):
18+
assert type(app.square_root(25)) == type(1.0)
19+
20+
@pytest.mark.it('Testing the function square_root with the number 50, it should return 7.07')
21+
def test_square_root_50(app):
22+
try:
23+
assert app.square_root(50) == 7.07
24+
except AttributeError:
25+
raise AttributeError("The function 'square_root' should return the value 7.07")
26+
27+
@pytest.mark.it('Testing the function square_root with the number 2.25, it should return 1.5')
28+
def test_square_root_2_25(app):
29+
try:
30+
assert app.square_root(2.25) == 1.5
31+
except AttributeError:
32+
raise AttributeError("The function 'square_root' should return the value 1.5")
33+
34+
@pytest.mark.it('Testing the function square_root with the number 0, it should return 0')
35+
def test_square_root_0(app):
36+
try:
37+
assert app.square_root(0) == 0
38+
except AttributeError:
39+
raise AttributeError("The function 'square_root' should return the value 0")

exercises/22-Integral/README.es.md exercises/022-Integral/README.es.md

+1-1

exercises/22-Integral/README.md exercises/022-Integral/README.md

+1-1
File renamed without changes.
File renamed without changes.
File renamed without changes.

exercises/23-list-and-tuple/README.es.md exercises/023-list-and-tuple/README.es.md

+1-1

exercises/23-list-and-tuple/README.md exercises/023-list-and-tuple/README.md

+1-1
File renamed without changes.
File renamed without changes.

exercises/24-class-with-two-methods/README.es.md exercises/024-class-with-two-methods/README.es.md

+1-1

exercises/24-class-with-two-methods/README.md exercises/024-class-with-two-methods/README.md

+1-1

exercises/25-print-formula/README.es.md exercises/025-print-formula/README.es.md

+1-1

exercises/25-print-formula/README.md exercises/025-print-formula/README.md

+1-1
File renamed without changes.
File renamed without changes.

exercises/26-two-dimensional-array/README.es.md exercises/026-two-dimensional-array/README.es.md

+1-1

exercises/26-two-dimensional-array/README.md exercises/026-two-dimensional-array/README.md

+1-1

exercises/27-sequence-of-words/README.es.md exercises/027-sequence-of-words/README.es.md

+1-1

exercises/27-sequence-of-words/README.md exercises/027-sequence-of-words/README.md

+1-1
File renamed without changes.
File renamed without changes.
+21
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Your code here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Your code here
2+
def lines(text):
3+
return text.upper()
4+
5+
print(lines('Hello world, practice makes perfect'))

exercises/28-sequence-of-lines/test.py exercises/028-sequence-of-lines/test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ def test_function_existence(capsys, app):
99
def test_expected_output(capsys, app):
1010
assert app.lines("hello world") == "HELLO WORLD"
1111

12-
@pytest.mark.it('The function should return the expected output')
12+
@pytest.mark.it('The function should return the expected output. Testing with a different value')
1313
def test_another_output(capsys, app):
1414
assert app.lines("LeT the WOrld know YoU") == "LET THE WORLD KNOW YOU"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Your code here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Your code here
2+
def remove_duplicate_words(text):
3+
words = text.split()
4+
return (" ".join(sorted(list(set(words)))))
5+
6+
print(remove_duplicate_words("hello world and practice makes perfect and hello world again"))

exercises/29-remove-duplicate-words/test.py exercises/029-remove-duplicate-words/test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ def test_function_existence(capsys, app):
88
def test_expected_output(capsys, app):
99
assert app.remove_duplicate_words("hello world and practice makes perfect and hello world again") == "again and hello makes perfect practice world"
1010

11-
@pytest.mark.it('The function should work with other entries')
11+
@pytest.mark.it('The function should work with other entries. Testing with different values')
1212
def test_expected_output_2(capsys, app):
1313
assert app.remove_duplicate_words("lets try this again with another try") == "again another lets this try with"
1414

15-
@pytest.mark.it('The function should work with other entries')
15+
@pytest.mark.it('The function should work with other entries. Testing with different values')
1616
def test_expected_output_3(capsys, app):
1717
assert app.remove_duplicate_words("Jacke was Named Jacke by his mother") == "Jacke Named by his mother was"
1818

+28

exercises/030-divisable-binary/app.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Your code here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Your code here
2+
def divisible_binary(binary_sequence):
3+
divisible_numbers = []
4+
binary_numbers = [x for x in binary_sequence.split(',')]
5+
for binary_num in binary_numbers:
6+
int_binary_num = int(binary_num, 2)
7+
if not int_binary_num % 5:
8+
divisible_numbers.append(binary_num)
9+
10+
return ','.join(divisible_numbers)
11+
12+
print(divisible_binary("1000,1100,1010,1111"))

0 commit comments

Comments
 (0)