Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ba9c6f7

Browse files
Merge pull request #70 from kiddopro/04.1-count_on
added hints
2 parents 5e7a115 + 0149681 commit ba9c6f7

File tree

4 files changed

+39
-19
lines changed

4 files changed

+39
-19
lines changed

‎exercises/04.1-count_on/README.es.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22

33
Como has visto en el ejercicio anterior tu lista puede ser un a mezcla de `tipos de datos` que vamos a dividir y conquistar.
44

5-
¿Serías tan amable de añadir todos los elementos con *data-type* `dict` y `list` dentro de la lista `hello`?
5+
¿Serías tan amable de añadir todos los elementos con *data-type* (tipo de dato) `dict` y `list` de la lista `my_list` en una nueva lista llamada `new_list`?
66

77
## 📝 Instrucciones:
88

9-
1. Itera la lista dada.
9+
1. Itera la lista dada (`my_list`).
1010

11-
2. Mete los tipos de datos encontrados en una nueva lista llamada `hello`.
11+
2. Mete los tipos de datos `dict` y `list`encontrados en una nueva lista llamada `new_list`.
1212

13-
3. Imprime la variable `hello`.
13+
3. Imprime la variable `new_list`.
1414

1515
## 💡 Pista:
1616

17+
+ Recuerda que puedes saber el tipo de dato de una variable o valor con la función `type()`
18+
19+
+ Para más información sobre la función `type()`: https://www.w3schools.com/python/ref_func_type.asp
20+
1721
Así es como puedes imprimir TODOS los elementos:
1822

1923
```py
@@ -22,6 +26,7 @@ my_list = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]
2226
for x in my_list:
2327
print(x)
2428
```
29+
2530
## Resultado esperado:
2631

2732
```py

‎exercises/04.1-count_on/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22

33
As you saw in the last exercise your list can be a mix `types of data` we are going to divide and conquer.
44

5-
Would you be so kind to add all the items with data-type `dict` and `list` into the hello list?
5+
Would you be so kind to add all the items with data-type `dict` and `list` of the list named `my_list` into a new list named `new_list`?
66

77
## 📝Instructions:
88

99
1. Loop the given list.
1010

11-
2. Push the data-types found to an new list called `hello`.
11+
2. Push the data-types `dict` and `list`found to a new list called `new_list`.
1212

13-
3. Print the variable `hello`.
13+
3. Print the variable `new_list`.
1414

1515
## 💡 Hint :
1616

17+
+ Remember that you can know the data-type of a variable or value with the function `type()`.
18+
19+
+ Check this link for more information about the `type()` function: https://www.w3schools.com/python/ref_func_type.asp
20+
1721
Here is how to print ALL the items.
1822

1923
```py

‎exercises/04.1-count_on/app.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
21
my_list = [42, True, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]
32

4-
53
#your code go here:
6-
7-
print(hello)

‎exercises/04.1-count_on/test.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
1-
import io, sys, os, pytest, re
1+
import io, sys, os, pytest, re, app
22
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
33

4-
@pytest.mark.it("Cool !!! 😎 You have the all data-type object")
5-
def test_all_data_type(capsys, app):
6-
app()
7-
captured = capsys.readouterr()
8-
assert "[[2, 1], {'name': 'juan'}]\n" in captured.out
4+
@pytest.mark.it("The variable 'new_list' should exist")
5+
def test_variable_exists():
6+
assert app.new_list != None
97

10-
@pytest.mark.it("Use the for loop")
8+
@pytest.mark.it("The variable 'new_list' value should contain data-types of 'dict' and 'list'")
9+
def test_variable_value():
10+
assert app.new_list == [[2, 1], {'name': 'juan'}]
11+
12+
@pytest.mark.it("You have to use a for loop")
1113
def test_for_loop():
1214
with open(path, 'r') as content_file:
1315
content = content_file.read()
1416
regex = re.compile(r"for(\s)")
1517
assert bool(regex.search(content)) == True
1618

17-
@pytest.mark.it("Use if statement")
19+
@pytest.mark.it("You have to use an if statement")
1820
def test_if():
1921
with open(path, 'r') as content_file:
2022
content = content_file.read()
2123
regex = re.compile(r"if(\s)")
2224
assert bool(regex.search(content)) == True
2325

26+
@pytest.mark.it("you should use print()")
27+
def test_print():
28+
with open(path, 'r') as content_file:
29+
content = content_file.read()
30+
regex = re.compile(r"print\(new_list\)")
31+
assert bool(regex.search(content)) == True
32+
33+
@pytest.mark.it("You have to print the value of the variable 'new_list' in the console")
34+
def test_all_data_type(capsys, app):
35+
app()
36+
captured = capsys.readouterr()
37+
38+
assert "[[2, 1], {'name': 'juan'}]\n" in captured.out

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /