-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from josemoracard/jose6-09.1-For_loop_min_value
exercises 09.1-for-loop-min-value to 12.1-More-mapping
- Loading branch information
Showing
27 changed files
with
197 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
"phone": "321-321-4321", | ||
"email": "[email protected]" | ||
} | ||
#Your code here: | ||
|
||
# Your code here | ||
|
10 changes: 10 additions & 0 deletions
10
exercises/10.1-And_One_and_a_Two_and_a_Three/solution.hide.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
Oops, something went wrong.