-
Notifications
You must be signed in to change notification settings - Fork 246
exercises 06-lambda-functions to 10-Array-Methods #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alesanchezr
merged 37 commits into
4GeeksAcademy:master
from
josemoracard:jose4-06-lambda-functions
Dec 6, 2023
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
b3fbd36
Update README.es.md
josemoracard a96cd35
Update README.es.md
josemoracard 117bc32
Update README.md
josemoracard b8b422f
Update README.md
josemoracard e1d8fe2
Update README.es.md
josemoracard 4ed8919
Update README.md
josemoracard d006197
Update app.py
josemoracard e158501
Update tests.py
josemoracard f7e459f
Update tests.py
josemoracard 0d2ba13
Update tests.py
josemoracard 0de3fbf
Create solution.hide.py
josemoracard 7877337
Update README.md
josemoracard 7c657c2
Update README.md
josemoracard 7f5cc84
Update README.es.md
josemoracard a18d892
Update app.py
josemoracard 0280a20
Update solution.hide.py
josemoracard daa03e4
Update tests.py
josemoracard 44a898b
Update README.md
josemoracard 930f773
Update README.md
josemoracard 08490fe
Update README.es.md
josemoracard eaefd88
Update app.py
josemoracard 50e2eec
Update test.py
josemoracard 114310e
Create solution.hide.py
josemoracard 989a756
Update README.md
josemoracard cecf0db
Update README.es.md
josemoracard 71fe9b0
Update solution.hide.py
josemoracard af4d5fd
Update README.es.md
josemoracard 91c9d46
Update README.md
josemoracard a5eafd9
Update README.md
josemoracard 3f6d997
Update README.md
josemoracard 8bfd0bc
Update README.es.md
josemoracard 4b35a98
Update solution.hide.py
josemoracard 3c02856
Update app.py
josemoracard a229f30
Update README.md
josemoracard 355a13a
Update tests.py
josemoracard b681c43
Update README.md
josemoracard a438081
Update README.es.md
josemoracard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,41 @@ | ||
# `06` Funciones Lambda en Python | ||
# `06` Lambda Functions in Python | ||
|
||
Una **función lambda** es una función con solo una línea de código y sin nombre. | ||
|
||
Es un tipo de función muy especial en el mundo Python porque puedes usarla como una 'pequeña utilidad' para una programación muy ágil: | ||
Es un tipo de función muy especial en el mundo Python porque puedes usarla como una pequeña utilidad para una programación muy ágil: | ||
|
||
```python | ||
# declarando una función normal para una multiplicación | ||
# Declarando una función normal para una multiplicación | ||
def multiply(p1, p2): | ||
return p1 * p2 | ||
|
||
# declarándola en una línea como una función lambda | ||
# Declarándola en una línea como una función lambda | ||
multiply = lambda p1,p2: p1 * p2 | ||
``` | ||
|
||
1. Las **funciones lambda** tiene que ser siempre muy pequeñas. | ||
### 👉 Caracteristicas: | ||
|
||
2. Las **funciones lambda** pueden tener únicamente una línea. | ||
+ Las **funciones lambda** tienen que ser siempre muy pequeñas. | ||
|
||
3. Las **funciones lambda** no necesitan un `return`, se asume que lo que haya en esa línea devolverá un valor. | ||
+ Las **funciones lambda** pueden tener únicamente una línea. | ||
|
||
4. Las **funciones lambda** pueden almacenarse en variables o ser pasadas como parámetro a otra función. | ||
+ Las **funciones lambda** no necesitan un `return`, se asume que lo que haya en esa línea devolverá un valor. | ||
|
||
+ Las **funciones lambda** pueden almacenarse en variables o ser pasadas como parámetro a otra función. | ||
|
||
|
||
## 📝 Instrucciones: | ||
|
||
1. Crea una variable llamada `is_odd`. | ||
|
||
2. Asígnale una función lambda que devuelva `True` o `False` dependiendo de si un número dado es impar o no. | ||
2. Asígnale una función **lambda** que devuelva `True` o `False` dependiendo de si un número dado es impar o no. | ||
|
||
## 💡 Pista: | ||
|
||
+ Así es como declararías una función normal: | ||
|
||
```python | ||
# Esta función retorna `True` si el número es impar | ||
# Esta función retorna "True" si el número es impar | ||
def is_odd(num): | ||
return (num % 2) != 0 | ||
``` |
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,2 +1,2 @@ | ||
# your function here | ||
# Your function 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,3 @@ | ||
# Your function here | ||
|
||
is_odd = lambda num: num % 2 != 0 |
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
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,5 +1,5 @@ | ||
|
||
|
||
|
||
# From this line above, plese do not change code below | ||
print(rapid("bob")) #should print bo | ||
# Your code above, please do not change code below | ||
print(rapid("bob")) # Should print "bo" |
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,5 +1,4 @@ | ||
rapid = lambda myStr: myStr[:-1] | ||
|
||
|
||
# From this line above, plese do not change code below | ||
print(rapid("bob")) #should print bo | ||
# Your code above, please do not change code below | ||
print(rapid("bob")) # Should print "bo" |
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
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,7 @@ | ||
def dollar_to_euro(dollar_value): | ||
return dollar_value * 0.89 | ||
return dollar_value * 0.91 | ||
|
||
def euro_to_yen(euro_value): | ||
return euro_value * 124.15 | ||
return euro_value * 161.70 | ||
|
||
####### ↓ YOUR CODE BELOW ↓ ####### | ||
####### ↓ YOUR CODE BELOW ↓ ####### |
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,12 @@ | ||
def dollar_to_euro(dollar_value): | ||
return dollar_value * 0.91 | ||
|
||
def euro_to_yen(euro_value): | ||
return euro_value * 161.70 | ||
|
||
####### ↓ YOUR CODE BELOW ↓ ####### | ||
|
||
euros = dollar_to_euro(137) | ||
yen = euro_to_yen(euros) | ||
|
||
print(yen) |
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
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,7 @@ | ||
# Your code goes here: | ||
def render_person(name, birthdate, eye_color, age, sex): | ||
return name +" is a "+ str(age) +" years old " + sex +" born in " + birthdate + " with "+eye_color +" eyes" | ||
def render_person(name, birth_date, eye_color, age, gender): | ||
return name + " is a " + str(age) + " years old " + gender + " born in " + birth_date + " with " + eye_color + " eyes" | ||
|
||
|
||
# Do not edit below this line | ||
print(render_person('Bob', '05/22/1983', 'green', 23, 'male')) | ||
print(render_person('Bob', '05/22/1983', 'green', 23, 'male')) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caterísticas