Skip to content

Commit

Permalink
Merge pull request #115 from josemoracard/jose6-09.1-For_loop_min_value
Browse files Browse the repository at this point in the history
exercises 09.1-for-loop-min-value to 12.1-More-mapping
  • Loading branch information
alesanchezr authored Dec 6, 2023
2 parents 65abfe8 + 85d3c7a commit 7c64f4a
Show file tree
Hide file tree
Showing 27 changed files with 197 additions and 166 deletions.
18 changes: 9 additions & 9 deletions exercises/09.1-For_loop_min_value/README.es.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# `09.1` Minimum integer
# `09.1` Minimum Integer

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

## 📝 Instrucciones:

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

## 💡 Pista:
## 💡 Pistas:

* Declara una variable auxiliar global.
+ Declara una variable auxiliar global.

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

* 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.
+ 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.

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

## Resultado esperado:
## 💻 Resultado esperado:

```py
23
Expand Down
21 changes: 10 additions & 11 deletions exercises/09.1-For_loop_min_value/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# `09.1` Minimum integer:
# `09.1` Minimum Integer

It is possible to traverse a list using the `for` loop, you have to specify what to do on each iteration of the loop.
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.

## 📝 Instructions:

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

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

## 💡 Hint:
+ Declare an auxiliary global variable.

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

* Set it's value to a very big interger.
+ 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.

* 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.
+ Outside the loop, after the loop is finished, print the auxiliary variable's value.

* Outside of the loop, after the loop is finished, print the auxiliary value.

## Expected result:
## 💻 Expected result:

```py
23
Expand Down
8 changes: 2 additions & 6 deletions exercises/09.1-For_loop_min_value/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
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]
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]

#Your code here:
# Your code here
13 changes: 8 additions & 5 deletions exercises/09.1-For_loop_min_value/solution.hide.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
big_number = 999999999999999
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]

# Your code here

smallest_integer = my_list[0]

for number in my_list:
if number < big_number:
big_number = number
if number < smallest_integer:
smallest_integer = number


print(big_number)
print(smallest_integer)
4 changes: 2 additions & 2 deletions exercises/09.1-For_loop_min_value/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def test_for_loop():
regex = re.compile(r"for(\s)")
assert bool(regex.search(content)) == True

@pytest.mark.it("Use if statement")
@pytest.mark.it("Use an if statement")
def test_if():
with open(path, 'r') as content_file:
content = content_file.read()
regex = re.compile(r"if(\s)")
assert bool(regex.search(content)) == True
assert bool(regex.search(content)) == True
21 changes: 10 additions & 11 deletions exercises/10-Find_avg/README.es.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# `10` Find the average
# `10` Find average

## 📝 Instrucciones:

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

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

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

```py
El resultado debería ser similar a:
27278.8125
```
+ Debes usar un bucle `for`.

## 💡 Pistas:
+ Puedes usar tantas variables auxiliares como necesites.

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

+ Debes usar un ciclo for.
```py
27278.8125
```
21 changes: 10 additions & 11 deletions exercises/10-Find_avg/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# `10` Find average

## 📝Instructions:
## 📝 Instructions:

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

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

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

```py
The result have to be like:
27278.8125
```
+ Make sure you are using a `for` loop.

## 💡 Hints:
+ You can use as many auxiliary variables as you need.

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

+ Make sure you are using a for loop.
```py
27278.8125
```
2 changes: 1 addition & 1 deletion exercises/10-Find_avg/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
my_list = [2323,4344,2325,324413,21234,24531,2123,42234,544,456,345,42,5445,23,5656,423]

#Your code here:
# Your code here
11 changes: 11 additions & 0 deletions exercises/10-Find_avg/solution.hide.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
my_list = [2323,4344,2325,324413,21234,24531,2123,42234,544,456,345,42,5445,23,5656,423]

# Your code here
total = 0

for num in my_list:
total += num

average = total / len(my_list)

print(average)
18 changes: 8 additions & 10 deletions exercises/10.1-And_One_and_a_Two_and_a_Three/README.es.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
# `10.1` And one and two and three

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.
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.

## 📝 Instrucciones:

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

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

## 💡 Pista:
## 💡 Pistas:

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

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

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

## Resultado esperado:
## 💻 Ejemplo de resultado:

```py
Ejemplo de salida:

fullname : John Doe
phone : 123-123-2134
email : test@nowhere.com
fullname: John Doe
phone: 123-123-2134
email: test@nowhere.com
```
22 changes: 11 additions & 11 deletions exercises/10.1-And_One_and_a_Two_and_a_Three/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# `10.1` And one and two and three

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.
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.

## 📝Instructions:
## 📝 Instructions:

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

2. You will have to loop its properties to be able to print them.
2. You will have to loop over its keys to be able to print them.

## 💡Hint:
## 💡 Hints:

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

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

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

## Example console output:
## 💻 Example console output:

```py
fullname : John Doe
phone : 123-123-2134
email : test@nowhere.com
```
fullname: John Doe
phone: 123-123-2134
email: test@nowhere.com
```
3 changes: 2 additions & 1 deletion exercises/10.1-And_One_and_a_Two_and_a_Three/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"phone": "321-321-4321",
"email": "[email protected]"
}
#Your code here:

# Your code here

10 changes: 10 additions & 0 deletions exercises/10.1-And_One_and_a_Two_and_a_Three/solution.hide.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
contact = {
"fullname": "Jane Doe",
"phone": "321-321-4321",
"email": "[email protected]"
}

# Your code here

for key in contact.keys():
print(f"{key}: {contact[key]}")
15 changes: 7 additions & 8 deletions exercises/11-Nested_list/README.es.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
# `11` Nested list


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

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

```py
longitude = []
# bucle for en longitud
longitude = coordinatesList[0][1];
# La primera coordenada es latitud
latitude = coordinates_list[0][0]
# La segunda coordenada es longitud
longitude = coordinates_list[0][1]
```

## 📝 Instrucciones:

1. Itera la lista imprimiendo solo las longitudes.
1. Itera la lista imprimiendo solo las *longitudes*.

## 💡 Pista:

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

## Resultado esperado:
## 💻 Resultado esperado:

```py
El resultado debería ser algo como esto:
-112.633853
-63.987
-81.901693
Expand Down
20 changes: 9 additions & 11 deletions exercises/11-Nested_list/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
# `11` Nested list

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

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

```py
longitude = []

for loop in coordinate longitude

longitude = coordinatesList[0][1];
# The first coordinate is latitude
latitude = coordinates_list[0][0]
# The second coordinate is longitude
longitude = coordinates_list[0][1]
```

## 📝Instructions:
## 📝 Instructions:

1. Loop through the list printing only the longitudes.
1. Loop through the list, printing only the *longitudes*.

## 💡 Hint:

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

## Expected result:
## 💻 Expected result:

```py
The result should be something like this:
-112.633853
-63.987
-81.901693
Expand Down
7 changes: 2 additions & 5 deletions exercises/11-Nested_list/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
coordinates_list = [[33.747252, -112.633853], [-33.867886, -63.987], [41.303921, -81.901693], [-33.350534, -71.653268]]

coordinatesList = [[33.747252,-112.633853],[-33.867886, -63.987],[41.303921, -81.901693],[-33.350534, -71.653268]]

# Your code go here:


# Your code here
6 changes: 6 additions & 0 deletions exercises/11-Nested_list/solution.hide.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coordinates_list = [[33.747252, -112.633853], [-33.867886, -63.987], [41.303921, -81.901693], [-33.350534, -71.653268]]

# Your code here

for coord in coordinates_list:
print(coord[1])
Loading

0 comments on commit 7c64f4a

Please sign in to comment.