Skip to content

Commit 98144e7

Browse files
committed
fixed issues 07-08-09-17-18
1 parent 8500ea0 commit 98144e7

8 files changed

Lines changed: 15 additions & 30 deletions

File tree

exercises/07-Create-a-Basic-HTML/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ the variables and concatenate them together to set the value of the variable **h
1212
a new string that has the content of a typical HTML document (with the HTML tags in the
1313
right order).
1414

15-
2. Then, print the value of html_document on the console.
15+
2. Then, print the value of **html_document** on the console.
1616

1717
The output should look like this:
1818

exercises/07-Create-a-Basic-HTML/app.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@
99

1010
# DON'T CHANGE THE CODE ABOVE
1111

12-
html_document = e + c + g + a + f + h + d + b
13-
print(html_document)

exercises/07-Create-a-Basic-HTML/test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@
1111

1212
@pytest.mark.it('1. Your code needs to print a basic html layout on the console')
1313
def test_for_file_output(capsys):
14+
regex = r"print(\s*)\(html_document\)"
15+
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
16+
content = f.readlines()
17+
content = [x.strip() for x in content]
18+
# indices = [i for i, s in enumerate(content) if 'print' in s]
19+
# print(int(indices))
20+
my_print = [s for s in content if "print" in s]
21+
my_print_index = content.index(my_print[0])
1422
captured = buffer.getvalue()
23+
assert re.match(regex, content[my_print_index])
1524
assert captured == "<html><head><title></title></head><body></body></html>\n" #add \n because the console jumps the line on every print
1625
@pytest.mark.it("2. You should create a variable named html_document")
1726
def test_use_my_var1():
@@ -24,12 +33,3 @@ def test_use_my_var1():
2433
# print(my_print_index)
2534
regex = r"html_document(\s*)=(\s*)e(\s*)\+(\s*)c(\s*)\+(\s*)g(\s*)\+(\s*)a(\s*)\+(\s*)f(\s*)\+(\s*)h(\s*)\+(\s*)d(\s*)\+(\s*) b"
2635
assert re.match(regex, content[my_htmlDocumentIndex])
27-
# @pytest.mark.it('Your function needs to print "Hello Inside Function" on the console')
28-
# def test_for_function_output(capsys):
29-
# my_function()
30-
# captured = capsys.readouterr()
31-
# assert captured.out == "Hello Inside Function\n"
32-
33-
# @pytest.mark.it('Your function needs to return True')
34-
# def test_for_function_return(capsys):
35-
# assert my_function() == True

exercises/08-Calling-Your-First-Function/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ def is_odd(my_number):
22
return (my_number % 2 != 0)
33

44

5-
# your code here
6-
print(is_odd(45345))
5+
# your code here

exercises/08-Calling-Your-First-Function/test.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,3 @@ def test_conditional():
2525
def test_for_file_output(capsys):
2626
captured = buffer.getvalue()
2727
assert captured == "True\n"
28-
# @pytest.mark.it('Your function needs to print "Hello Inside Function" on the console')
29-
# def test_for_function_output(capsys):
30-
# my_function()
31-
# captured = capsys.readouterr()
32-
# assert captured.out == "Hello Inside Function\n"
33-
34-
# @pytest.mark.it('Your function needs to return True')
35-
# def test_for_function_return(capsys):
36-
# assert my_function() == True

exercises/09-Creating-Your-First-Function/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_use_my_var1():
1515
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
1616
content = f.readlines()
1717
content = [x.strip() for x in content]
18-
my_return = [s for s in content if "return a+b" in s]
18+
my_return = [s for s in content if "return" in s]
1919
my_returnIndex = content.index(my_return[0])
2020
# print(my_print_index)
2121
regex = r"return a(\s*)\+(\s*)b"

exercises/17-While-Loop/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Fix the problem, to print from 100 - 0. And return 0.
66

77
## 💡 Hint:
88

9-
- To stop the infinite loop press **ctrl + c** and then run again **bc run:exercises -e=gitpod**
9+
- To stop the infinite loop press **ctrl + c** (It could take a while before it stops, be patient!)and then run again **bc run:exercises -e=gitpod**
1010

1111

1212
IMPORTANT: there's a Classroom Exercise dedicated to Arrays, we encourage you to go and finish those after this first Array exercise. (And then, come back).

exercises/18-Random-Colors-Loop/app.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ def get_color(color_number=4):
1616

1717
def get_allStudentColors():
1818

19-
#your loop here
2019
example_color = 1
2120
students_array = []
21+
#your loop here
22+
2223

23-
for i in range(11):
24-
example_color = get_color(random.randint(0,4))
25-
students_array.append(example_color)
26-
return students_array
2724

2825

2926

0 commit comments

Comments
 (0)