Skip to content

Commit 7c64f4a

Browse files
authored
Merge pull request 4GeeksAcademy#115 from josemoracard/jose6-09.1-For_loop_min_value
exercises 09.1-for-loop-min-value to 12.1-More-mapping
2 parents 65abfe8 + 85d3c7a commit 7c64f4a

27 files changed

+197
-166
lines changed

exercises/09.1-For_loop_min_value/README.es.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
# `09.1` Minimum integer
1+
# `09.1` Minimum Integer
22

3-
Es posible recorrer una lista usando un bucle `for` para listas, tú tienes que especificar qué hacer en cada iteración de la lista.
3+
Es posible recorrer una lista usando un bucle `for`, y luego especificar qué hacer en cada iteración de la lista.
44

55
## 📝 Instrucciones:
66

7-
1. Por favor, usa la función for para obtener el menor valor de la lista e imprimirlo en la consola.
7+
1. Por favor, usa la función `for` para obtener el menor valor de la lista e imprimirlo en la consola.
88

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

11-
* Declara una variable auxiliar global.
11+
+ Declara una variable auxiliar global.
1212

13-
* Establece su valor inicial con un entero muy grande.
13+
+ Establece su valor inicial con el primer elemento de la lista.
1414

15-
* Cada vez que iteres, compara su valor con el valor del elemento, si el valor del elemento es más pequeño, asígnalo como nuevo valor de la variable auxiliar.
15+
+ Cada vez que iteres, compara su valor con el valor del siguiente elemento, si el valor del elemento es más pequeño, asígnalo como nuevo valor en la variable auxiliar.
1616

17-
* Fuera del bucle, después de que el bucle haya finalizado, imprime el valor auxiliar.
17+
+ Fuera del bucle, después de que el bucle haya finalizado, imprime el valor auxiliar.
1818

19-
## Resultado esperado:
19+
## 💻 Resultado esperado:
2020

2121
```py
2222
23

exercises/09.1-For_loop_min_value/README.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
# `09.1` Minimum integer:
1+
# `09.1` Minimum Integer
22

3-
It is possible to traverse a list using the `for` loop, you have to specify what to do on each iteration of the loop.
3+
It is possible to traverse a list using the `for` loop, and you have to specify what to do on each iteration of the loop.
44

5+
## 📝 Instructions:
56

6-
## 📝Instructions:
7+
1. Please use the `for` loop function to get the minimum value from the list and print it in the console.
78

8-
1. Please use the `for` loop function to get the minimum value of the list and print it in the console.
9+
## 💡 Hints:
910

10-
## 💡 Hint:
11+
+ Declare an auxiliary global variable.
1112

12-
* Declare an Auxiliary Global Variable.
13+
+ Set its value to the first element on the list.
1314

14-
* Set it's value to a very big interger.
15+
+ Every time you loop, compare its value to the next element's value, if it's smaller, update the auxiliary variable's value to the element's value.
1516

16-
* Every time you loop, compare it's value to the item value. If the item value is smaller, update the auxiliary variable value to the item value.
17+
+ Outside the loop, after the loop is finished, print the auxiliary variable's value.
1718

18-
* Outside of the loop, after the loop is finished, print the auxiliary value.
19-
20-
## Expected result:
19+
## 💻 Expected result:
2120

2221
```py
2322
23
+2-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
my_list = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,
2-
43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,
3-
425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,
4-
566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,
5-
35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343]
1+
my_list = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343]
62

7-
#Your code here:
3+
# Your code here
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
big_number = 999999999999999
1+
my_list = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343]
2+
3+
# Your code here
4+
5+
smallest_integer = my_list[0]
26

37
for number in my_list:
4-
if number < big_number:
5-
big_number = number
8+
if number < smallest_integer:
9+
smallest_integer = number
610

7-
8-
print(big_number)
11+
print(smallest_integer)

exercises/09.1-For_loop_min_value/test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def test_for_loop():
1414
regex = re.compile(r"for(\s)")
1515
assert bool(regex.search(content)) == True
1616

17-
@pytest.mark.it("Use if statement")
17+
@pytest.mark.it("Use an if statement")
1818
def test_if():
1919
with open(path, 'r') as content_file:
2020
content = content_file.read()
2121
regex = re.compile(r"if(\s)")
22-
assert bool(regex.search(content)) == True
22+
assert bool(regex.search(content)) == True

exercises/10-Find_avg/README.es.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
# `10` Find the average
1+
# `10` Find average
22

33
## 📝 Instrucciones:
44

5-
1. Declara una variable con valor `0`.
5+
1. Calcula el valor promedio de todos los elementos de la lista e imprímelo en la consola.
66

7-
2. Calcula el valor promedio de todos los elementos de la lista e imprímelo en la consola.
7+
## 💡 Pistas:
88

9-
## Resultado esperado:
9+
+ Para imprimir el promedio, tienes que sumar todos los valores y dividir el total entre la cantidad de elementos de la lista.
1010

11-
```py
12-
El resultado debería ser similar a:
13-
27278.8125
14-
```
11+
+ Debes usar un bucle `for`.
1512

16-
## 💡 Pistas:
13+
+ Puedes usar tantas variables auxiliares como necesites.
1714

18-
+ Para imprimir el promedio, tienes que sumar todos los valores y dividir el total entre la cantidad de elementos de la lista.
15+
## 💻 Resultado esperado:
1916

20-
+ Debes usar un ciclo for.
17+
```py
18+
27278.8125
19+
```

exercises/10-Find_avg/README.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
# `10` Find average
22

3-
## 📝Instructions:
3+
## 📝 Instructions:
44

5-
1. Declare a variable with value `0`.
5+
1. Calculate the average value of all the items in the list and print it on the console.
66

7-
2. Calculate the average value of all the items in the list and print it on the console.
7+
## 💡 Hints:
88

9-
## Expected result:
9+
+ To print the average, you have to add all the values and divide the result by the total length of the list.
1010

11-
```py
12-
The result have to be like:
13-
27278.8125
14-
```
11+
+ Make sure you are using a `for` loop.
1512

16-
## 💡 Hints:
13+
+ You can use as many auxiliary variables as you need.
1714

18-
+ To print the average, you have to add all the values and divide the result by the total length of the list.
15+
## 💻 Expected result:
1916

20-
+ Make sure you are using a for loop.
17+
```py
18+
27278.8125
19+
```

exercises/10-Find_avg/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
my_list = [2323,4344,2325,324413,21234,24531,2123,42234,544,456,345,42,5445,23,5656,423]
22

3-
#Your code here:
3+
# Your code here
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
my_list = [2323,4344,2325,324413,21234,24531,2123,42234,544,456,345,42,5445,23,5656,423]
2+
3+
# Your code here
4+
total = 0
5+
6+
for num in my_list:
7+
total += num
8+
9+
average = total / len(my_list)
10+
11+
print(average)
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
# `10.1` And one and two and three
22

3-
Los diccionarios (o `dict` en Python) son una forma de almacenar elementos como lo harías en una lista de Python, con la diferencia de que en lugar de acceder a los elementos por su índice, asignas una clave fija a cada uno y accedes al elemento usando su clave. A lo que te enfrentas ahora es un par `key-value` ("clave-valor"), el cual es, en ocasiones, una estructura de datos más apropiada para muchos problemas, en lugar de una simple lista.
3+
Los diccionarios (o "dict" en Python) son una forma de almacenar elementos como lo harías en una lista de Python, con la diferencia de que en lugar de acceder a los elementos por su índice, asignas una clave fija a cada uno y accedes al elemento usando su clave. A lo que te enfrentas ahora es a un par `key-value` (clave-valor), el cual es, en ocasiones, una estructura de datos más apropiada para diferentes problemas, en lugar de una simple lista.
44

55
## 📝 Instrucciones:
66

7-
1. Dado un objeto `contact`, por favor **itera todas sus propiedades y valores** e imprímelos en la consola.
7+
1. Dado un objeto `contact`, por favor itera todas sus claves y valores e imprímelos en la consola.
88

99
2. Tendrás que iterar sus propiedades para poder imprimirlos
1010

11-
## 💡 Pista:
11+
## 💡 Pistas:
1212

1313
- contact.keys() `['fullname', 'phone', 'email']`.
1414

1515
- contact.values() `['Jane Doe', '321-321-4321', '[email protected]']`.
1616

17-
- contact.items() `[('fullname', 'Jane Doe'), ('phone', '321-321-4321'), ``('email', '[email protected]')]`
17+
- contact.items() `[('fullname', 'Jane Doe'), ('phone', '321-321-4321'), ('email', '[email protected]')]`
1818

19-
## Resultado esperado:
19+
## 💻 Ejemplo de resultado:
2020

2121
```py
22-
Ejemplo de salida:
23-
24-
fullname : John Doe
25-
phone : 123-123-2134
26-
email : test@nowhere.com
22+
fullname: John Doe
23+
phone: 123-123-2134
24+
email: test@nowhere.com
2725
```
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# `10.1` And one and two and three
22

3-
Dictionaries (or dict in Python) are a way of storing elements just like you would in a Python list but intead of accessing elements using its index, you assign a fixed key to it and access the element using the key. What you now deal with is a `key-value` pair, which is sometimes a more appropriate data structure or many problems instead of a simple list.
3+
Dictionaries (or "dict" in Python) are a way of storing elements just like you would in a Python list, but instead of accessing elements using its index, you assign a fixed key to it and access the element using the key. What you now deal with is a `key-value` pair, which is sometimes a more appropriate data structure for solving different problems than a simple list.
44

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

7-
1. Given a contact object, please `loop all its properties and values` and print them on the console.
7+
1. Given a contact dictionary, please loop through all its keys and values and print them on the console.
88

9-
2. You will have to loop its properties to be able to print them.
9+
2. You will have to loop over its keys to be able to print them.
1010

11-
## 💡Hint:
11+
## 💡 Hints:
1212

1313
- contact.keys() `['fullname', 'phone', 'email']`
1414

1515
- contact.values() `['Jane Doe', '321-321-4321', '[email protected]']`
1616

17-
- contact.items() `[('fullname', 'Jane Doe'), ('phone', '321-321-4321'), ``('email', '[email protected]')]`
17+
- contact.items() `[('fullname', 'Jane Doe'), ('phone', '321-321-4321'), ('email', '[email protected]')]`
1818

19-
## Example console output:
19+
## 💻 Example console output:
2020

2121
```py
22-
fullname : John Doe
23-
phone : 123-123-2134
24-
email : test@nowhere.com
25-
```
22+
fullname: John Doe
23+
phone: 123-123-2134
24+
email: test@nowhere.com
25+
```

exercises/10.1-And_One_and_a_Two_and_a_Three/app.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"phone": "321-321-4321",
44
"email": "[email protected]"
55
}
6-
#Your code here:
6+
7+
# Your code here
78

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
contact = {
2+
"fullname": "Jane Doe",
3+
"phone": "321-321-4321",
4+
"email": "[email protected]"
5+
}
6+
7+
# Your code here
8+
9+
for key in contact.keys():
10+
print(f"{key}: {contact[key]}")

exercises/11-Nested_list/README.es.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
# `11` Nested list
22

3-
43
Es posible encontrar una lista dentro de otra lista (se llama lista de dos dimensiones o matriz).
54

65
En este ejemplo, tenemos una lista de coordenadas a las que puedes acceder haciendo lo siguiente:
76

87
```py
9-
longitude = []
10-
# bucle for en longitud
11-
longitude = coordinatesList[0][1];
8+
# La primera coordenada es latitud
9+
latitude = coordinates_list[0][0]
10+
# La segunda coordenada es longitud
11+
longitude = coordinates_list[0][1]
1212
```
1313

1414
## 📝 Instrucciones:
1515

16-
1. Itera la lista imprimiendo solo las longitudes.
16+
1. Itera la lista imprimiendo solo las *longitudes*.
1717

1818
## 💡 Pista:
1919

20-
* Recuerda que el índice en la primera posición es list[0].
20+
+ Recuerda que el índice en la primera posición es `list[0]`.
2121

22-
## Resultado esperado:
22+
## 💻 Resultado esperado:
2323

2424
```py
25-
El resultado debería ser algo como esto:
2625
-112.633853
2726
-63.987
2827
-81.901693

exercises/11-Nested_list/README.md

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
# `11` Nested list
22

3-
It is possible to find a list comprised of other lists (it is called a two-dimension list or matrix).
3+
It is possible to find a list comprised of other lists (it is called a two-dimensional list or matrix).
44

55
In this example, we have a list of coordinates that you can access by doing the following:
66

77
```py
8-
longitude = []
9-
10-
for loop in coordinate longitude
11-
12-
longitude = coordinatesList[0][1];
8+
# The first coordinate is latitude
9+
latitude = coordinates_list[0][0]
10+
# The second coordinate is longitude
11+
longitude = coordinates_list[0][1]
1312
```
1413

15-
## 📝Instructions:
14+
## 📝 Instructions:
1615

17-
1. Loop through the list printing only the longitudes.
16+
1. Loop through the list, printing only the *longitudes*.
1817

1918
## 💡 Hint:
2019

21-
- Remember the index of the position 1 is list[0]
20+
+ Remember, the index of the first item in a list is `list[0]`.
2221

23-
## Expected result:
22+
## 💻 Expected result:
2423

2524
```py
26-
The result should be something like this:
2725
-112.633853
2826
-63.987
2927
-81.901693

exercises/11-Nested_list/app.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1+
coordinates_list = [[33.747252, -112.633853], [-33.867886, -63.987], [41.303921, -81.901693], [-33.350534, -71.653268]]
12

2-
coordinatesList = [[33.747252,-112.633853],[-33.867886, -63.987],[41.303921, -81.901693],[-33.350534, -71.653268]]
3-
4-
# Your code go here:
5-
6-
3+
# Your code here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
coordinates_list = [[33.747252, -112.633853], [-33.867886, -63.987], [41.303921, -81.901693], [-33.350534, -71.653268]]
2+
3+
# Your code here
4+
5+
for coord in coordinates_list:
6+
print(coord[1])

0 commit comments

Comments
 (0)