Skip to content

Commit d9a4e02

Browse files
authored
Merge pull request #116 from josemoracard/jose7-12.2-Map_function_inside_variable
exercises 12.2-Map_function_inside_variable to 16-Techno_beat
2 parents 7c64f4a + 9411754 commit d9a4e02

Some content is hidden

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

76 files changed

+458
-314
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
!/exercises/*
1414

1515
*.pyc
16-
__pycache__/
16+
1717
.pytest_cache/
1818

1919
!/.learn

exercises/12.2-Map_function_inside_variable/README.es.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# `12.2` Map function inside a variable
22

3-
La variable names contiene muchos nombres 😒 (daah...)
3+
La variable `names` contiene muchos nombres (😒 daah...)
44

5-
La función `prepender` almacenada en la variable devuelve lo que sea que se le pase pero agregando antes: `'My name is:'`
5+
La función ya definida `prepender` devuelve lo que sea que se le pase pero agregando antes: `'My name is: '`.
66

77
## 📝 Instrucciones:
88

99
1. Por favor, mapea la lista de nombres usando la función `prepender` para crear una nueva lista que se parezca a esto:
1010

11-
## Resultado Esperado:
11+
## 💻 Resultado esperado:
1212

1313
```py
1414
[ 'My name is: Alice',

exercises/12.2-Map_function_inside_variable/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# `12.2` Map function inside a variable
22

3-
The variable names contains a lot of names (:unamused: dugh...)
3+
The variable `names` contains a lot of names (😒 duh...)
44

5-
The function stored in the variable `prepender` returns whatever is passed to it but prepended with the string: `'My name is:'`.
5+
The already defined function `prepender` returns whatever is passed to it but is prepended with the string: `'My name is: '`.
66

7-
## 📝Instructions:
7+
## 📝 Instructions:
88

9-
1. Please map the names list using the `prepender` function
10-
to create a new list that looks like this:
9+
1. Please map the names list using the `prepender` function to create a new list that looks like this:
1110

12-
## Expected Result:
11+
## 💻 Expected result:
1312

1413
```py
1514
[ 'My name is: Alice',
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
names = ['Alice','Bob','Marry','Joe','Hilary','Stevia','Dylan']
1+
names = ['Alice', 'Bob', 'Marry', 'Joe', 'Hilary', 'Stevia', 'Dylan']
22

33
def prepender(name):
44
return "My name is: " + name
5-
#Your code go here:
5+
6+
# Your code here
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
names = ['Alice', 'Bob', 'Marry', 'Joe', 'Hilary', 'Stevia', 'Dylan']
2+
3+
def prepender(name):
4+
return "My name is: " + name
5+
6+
# Your code here
7+
8+
new_list = list(map(prepender, names))
9+
10+
print(new_list)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import io, sys, pytest, os, re
22
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
33

4-
@pytest.mark.it("Print the all the names as in the output")
4+
@pytest.mark.it("Print all the names as in the output")
55
def test_multp(capsys, app):
66
import app
77
captured = capsys.readouterr()
@@ -11,4 +11,4 @@ def test_multp(capsys, app):
1111
def test_map():
1212
f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py')
1313
content = f.read()
14-
assert content.find("map") > 0
14+
assert content.find("map") > 0

exercises/12.3-Map_data_types/README.es.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# `12.3` Map data type
1+
# `12.3` Map data types
22

33
Muchas veces las listas vienen con valores mixtos y necesitamos unificarlos dentro de un solo tipo de datos.
44

55
## 📝 Instrucciones:
66

77
1. Actualiza la función `type_list()` para hacer que cree una nueva lista (`new_list`) que contenga el tipo de dato que corresponde a cada elemento de la lista original.
88

9-
## 💡 Pista:
9+
## 💡 Pistas:
1010

1111
+ Usa la función `type()` para obtener el tipo de dato.
1212

1313
+ Más sobre tipos de datos: https://www.w3schools.com/python/python_datatypes.asp
1414

15-
## Resultado esperado:
15+
## 💻 Resultado esperado:
1616

1717
```py
1818
[<class 'str'>, <class 'str'>, <class 'str'>, <class 'str'>, <class 'str'>, <class 'str'>, <class 'int'>, <class 'int'>]

exercises/12.3-Map_data_types/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# `12.3` Map data types
22

3-
Some times lists come with mixed values and you need to unify them into only one data type.
3+
Sometimes lists come with mixed values, and you need to unify them into only one data type.
44

5-
## 📝Instructions:
5+
## 📝 Instructions:
66

7-
1. Update the map function to make it create a **new list** that contains the data types of each corresponding item from the original list.
7+
1. Update the `type_list` function to make it create a `new_list` that contains the data types of each corresponding item from the original list.
88

9-
## 💡 Hint:
9+
## 💡 Hints:
1010

1111
+ Use the `type()` function to get the data type.
1212

1313
+ More about data type: https://www.w3schools.com/python/python_datatypes.asp
1414

15-
## Expected result:
15+
## 💻 Expected result:
1616

1717
```py
1818
[<class 'str'>, <class 'str'>, <class 'str'>, <class 'str'>, <class 'str'>, <class 'str'>, <class 'int'>, <class 'int'>]

exercises/12.3-Map_data_types/app.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
list_Strings = ['1','5','45','34','343','34',6556,323]
2-
1+
mixed_list = ['1','5','45','34','343','34',6556,323]
32

43
def type_list(items):
5-
return items
4+
# Your code here
5+
return
6+
7+
new_list = list(map(type_list, mixed_list))
68

7-
new_list = list(map(type_list, list_Strings))
8-
print(new_list)
9+
print(new_list)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
mixed_list = ['1','5','45','34','343','34',6556,323]
2+
3+
def type_list(items):
4+
# Your code here
5+
return type(items)
6+
7+
new_list = list(map(type_list, mixed_list))
8+
9+
print(new_list)

0 commit comments

Comments
 (0)