Skip to content

Commit a13d04e

Browse files
committed
making html exercise
1 parent b126e0d commit a13d04e

File tree

6 files changed

+37
-22
lines changed

6 files changed

+37
-22
lines changed

exercises/13.4-Making_HTML_with_filter_and_maP/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55
```py
66
Expexted:
77
<ul><li>Red</li><li>Orange</li><li>Pink</li><li>Violet</li></ul>
8-
```
8+
```
9+
10+
# 💡Hint:
11+
Maybe you have to use filter and map function
12+
Set values to the news variables

exercises/13.4-Making_HTML_with_filter_and_maP/app.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,3 @@
1010

1111
#Your code go here:
1212

13-
filter_colors = list(filter(lambda color: color["sexy"],all_colors))
14-
general_li = list(map(lambda color: "<li>"+color["label"]+"</li>", filter_colors))
15-
print("<ul>" + ''.join(general_li) + "</ul>")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import io
2+
import os
3+
import sys
4+
sys.stdout = buffer = io.StringIO()
5+
6+
import app
7+
import pytest
8+
9+
10+
@pytest.mark.it("Print the list of color in the console")
11+
def test_output():
12+
captured = buffer.getvalue()
13+
assert "\n" in captured
14+
15+
16+
@pytest.mark.it("Use the filter function")
17+
def test_filter():
18+
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
19+
content = f.read()
20+
assert content.find("filter")
21+
22+
23+
@pytest.mark.it("Use map function")
24+
def test_map():
25+
f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py')
26+
content = f.read()
27+
assert content.find("map")

exercises/14.1-Parking_lot_check/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ parking_state = [
1414
```
1515

1616
# 📝Instructions
17-
1. Create a function get_parking_lot() that returns an object with total_slots, available_slots and occupied_slots like the following:
17+
1. Create a function get_parking_lot() that returns an object
18+
with total_slots, available_slots and occupied_slots like the following:
1819
const state = {
1920
totalSlots: 12,
2021
availableSlots: 3,
@@ -23,3 +24,5 @@ const state = {
2324

2425
💡Hints
2526
You have to do a nested loop
27+
Declare a variables to store the value
28+
Compare the statements

exercises/14.1-Parking_lot_check/app.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,4 @@
66

77
#Your code go here:
88

9-
total = []
10-
occupied = []
11-
available = []
12-
parking_slots = {}
13-
14-
def get_parking_lot(spaces):
15-
for numb in spaces:
16-
for digit in numb:
17-
total.append(digit)
18-
if digit == 1:
19-
occupied.append(digit)
20-
elif digit == 2:
21-
available.append(digit)
22-
parking_slots.update({'total': len(total), 'occupied': len(occupied), 'available': len(available)})
23-
return parking_slots
24-
print(get_parking_lot(parking_state))
259

exercises/14.1-Parking_lot_check/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@pytest.mark.it("Print the object")
1010
def test_output():
1111
captured = buffer.getvalue()
12-
assert "\n" in captured
12+
assert "{'total': 9, 'occupied': 5, 'available': 1}\n" in captured
1313

1414
@pytest.mark.it("Create a get_parking_lot function")
1515
def test_function():

0 commit comments

Comments
 (0)