File tree Expand file tree Collapse file tree 6 files changed +37
-22
lines changed
13.4-Making_HTML_with_filter_and_maP Expand file tree Collapse file tree 6 files changed +37
-22
lines changed Original file line number Diff line number Diff line change 55``` py
66Expexted:
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
Original file line number Diff line number Diff line change 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>" )
Original file line number Diff line number Diff line change 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" )
Original file line number Diff line number Diff 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:
1819const state = {
1920 totalSlots: 12,
2021 availableSlots: 3,
@@ -23,3 +24,5 @@ const state = {
2324
2425💡Hints
2526You have to do a nested loop
27+ Declare a variables to store the value
28+ Compare the statements
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 99@pytest .mark .it ("Print the object" )
1010def 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" )
1515def test_function ():
You can’t perform that action at this time.
0 commit comments