Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

exercises 01-hello-world to 04-Call-a-function#52

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
23 commits
Select commitHold shift + click to select a range
95937fe
Update README.md
josemoracardNov 22, 2023
d4cd0b8
Update README.md
josemoracardNov 22, 2023
86ba89b
Update README.es.md
josemoracardNov 22, 2023
185c68c
Update README.md
josemoracardNov 22, 2023
849627e
Update README.md
josemoracardNov 22, 2023
c8d874b
Update README.es.md
josemoracardNov 22, 2023
fc6cc2c
Update README.es.md
josemoracardNov 22, 2023
bc3b370
Update app.py
josemoracardNov 22, 2023
ea6a0e2
Create solution.hide.py
josemoracardNov 22, 2023
d893571
Update solution.hide.py
josemoracardNov 22, 2023
16d9038
Update README.md
josemoracardNov 22, 2023
1a1fec3
Update README.md
josemoracardNov 22, 2023
3d4a114
Update README.es.md
josemoracardNov 22, 2023
1684f58
Create solution.hide.py
josemoracardNov 22, 2023
6040cfd
Update app.py
josemoracardNov 22, 2023
c0891c6
Update README.md
josemoracardNov 22, 2023
c822158
Update README.md
josemoracardNov 22, 2023
42fffee
Update README.md
josemoracardNov 22, 2023
2da7f65
Update README.md
josemoracardNov 22, 2023
772e9e5
Update README.es.md
josemoracardNov 22, 2023
0b953a0
Update app.py
josemoracardNov 22, 2023
9a62da1
Update solution.hide.py
josemoracardNov 22, 2023
bc85b65
Update tests.py
josemoracardNov 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletionsexercises/01-hello-world/README.es.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
#Aprende Funciones enPython!
#Welcome toPython Functions!

¡¡Nosestusiasma mucho tenerte aquí!! 🎉 😂
¡¡Nosentusiasma mucho tenerte aquí!! 🎉 😂

Presiona `Next →` en la esquina superior derecha cuando quieras empezar.

En este curso aprenderás los siguientes conceptos:

1. Cómo crear y llamar**funciones.**
1. Cómo crear y llamar funciones.

2. Construir tus primeras**funciones.**
2. Construir tus primeras funciones.

3.Sentirte cómod@ usando **funciones Lambda** en Python.
3.Practicar lasfunciones Lambda de Python.

4. Construir**funciones** con parámetros.
4. Construir funciones con parámetros.

5. Ejemplos de la vida real con**funciones**
5. Ejemplos de la vida real con funciones.

## Contributors

Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):

1. [Alejandro Sanchez (alesanchezr)](https://github.com/alesanchezr), contribution: (coder):computer: (idea) 🤔, (build-tests):warning:, (pull-request-review):eyes: (build-tutorial):white_check_mark: (documentation):book:
2. [Paolo (plucodev)](https://github.com/plucodev), contribución: (bug reports):bug: (coder):computer:, (traducción):earth_americas:
3. [Marco Gómez (marcogonzalo)](https://github.com/marcogonzalo), contribución: (bug reports):bug:, (traducción):earth_africa:
1. [Alejandro Sanchez (alesanchezr)](https://github.com/alesanchezr), contribution: (coder)💻, (idea) 🤔, (build-tests)⚠️, (pull-request-review)🤓, (build-tutorial)✅, (documentation)📖
2. [Paolo (plucodev)](https://github.com/plucodev), contribución: (bug reports)🐛, (coder)💻, (traducción)🌎
3. [Marco Gómez (marcogonzalo)](https://github.com/marcogonzalo), contribución: (bug reports)🐛, (traducción)🌎

This project follows the
[all-contributors](https://github.com/kentcdodds/all-contributors)
specification. Contributions of any kind are welcome!
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind are welcome!
26 changes: 12 additions & 14 deletionsexercises/01-hello-world/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,32 +2,30 @@
intro: "https://www.youtube.com/watch?v=awa_yfGgy9s"
---

#Learn Python Functions!
#Welcome to Python Functions!

We are very excited to have you here !! 🎉 😂

Click `next` on the top right ofthis instructions when you are ready to start.
Click `Next →` on the top right ofthese instructions when you are ready to start.

During this course you will be learning the following concepts:
During this course, you will be learning the following concepts:

1. Learning how to create and call**functions.***
1. Learning how to create and call functions.

2. Building your first real**functions**
2. Building your first real functions.

3. Get comfortable using Python**Lambda Functions**
3. Get comfortable using Python Lambda Functions.

4. Construct**functions** with parameters.
4. Construct functions with parameters.

5. Real life examples for**functions**
5. Real life examples for functions.

## Contributors

Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):

1. [Alejandro Sanchez (alesanchezr)](https://github.com/alesanchezr), contribution: (coder):computer: (idea) 🤔, (build-tests):warning:, (pull-request-review):eyes: (build-tutorial):white_check_mark: (documentation):book:
2. [Paolo (plucodev)](https://github.com/plucodev), contribution: (bug reports):bug:, contribution:(coder), (translation):earth_americas:
3. [Marco Gómez (marcogonzalo)](https://github.com/marcogonzalo), contribution: (bug reports):bug:, (translation):earth_africa:
1. [Alejandro Sanchez (alesanchezr)](https://github.com/alesanchezr), contribution: (coder)💻, (idea) 🤔, (build-tests)⚠️, (pull-request-review)🤓, (build-tutorial)✅, (documentation)📖
2. [Paolo (plucodev)](https://github.com/plucodev), contribution: (bug reports)🐛,(coder) 💻, (translation)🌎
3. [Marco Gómez (marcogonzalo)](https://github.com/marcogonzalo), contribution: (bug reports)🐛, (translation)🌎

This project follows the
[all-contributors](https://github.com/kentcdodds/all-contributors)
specification. Contributions of any kind are welcome!
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind are welcome!
11 changes: 6 additions & 5 deletionsexercises/02-Hello-World/README.es.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
# `02` Hello World

En Python, usamos`print` para hacer que el computador escriba cualquier cosa que queramos (el contenido de una variable, untexto dado, etc.) en algo llamado`la consola`.
En Python, usamos**print** para hacer que el computador escriba cualquier cosa que queramos (el contenido de una variable, unstring dado, etc.) en algo llamado"la consola".

Cadaidioma tiene **funciones** para integrarse con la consola, ya que al principio era la única forma de interactuar con los usuarios (antes de quellegara Windows o MacOS o Linux). Hoy en día, la impresión en la consola se utiliza (`print`) sobre todo como herramienta de monitoreo, ideal para dejar un rastro del contenido de las variables durante la ejecución del programa.
Cadalenguaje tiene **funciones** para integrarse con la consola, ya que al principio era la única forma de interactuar con los usuarios (antes de quellegaran Windows, Linux o macOS).

Este es un ejemplo de cómo usarlo
Hoy en día, la impresión en la consola se utiliza, sobre todo, como herramienta de monitoreo y depuración, ideal para dejar un rastro del contenido de las variables durante la ejecución del programa.

Este es un ejemplo de cómo usarla:

```py
print("How are you?")
Expand All@@ -16,5 +18,4 @@ print("How are you?")

## 💡 Pista:

+ :video_camera: Puedes ver este breve video (5 minutos) sobre la consola:
https://www.youtube.com/watch?v=vROGBvX_MHQ
+ 📹 Puedes ver este breve video (2 minutos) sobre la consola: https://www.youtube.com/watch?v=vROGBvX_MHQ
12 changes: 6 additions & 6 deletionsexercises/02-Hello-World/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,22 +4,22 @@ tutorial: "https://www.youtube.com/watch?v=voBO7a0KPtE"

# `02` Hello World

In Python, we use`print` to make the computer write anything we want (the content of a variable, a given string, etc.) in something called`the console`.
In Python, we use**print** to make the computer write anything we want (the content of a variable, a given string, etc.) in something called"the console".

Every language has **functions** to integrate with the console, as it was the only way to interact with the users at the beginning (beforetheWindows orLinux orMacOS arrived).
Every language has **functions** to integrate with the console, as it was the only way to interact with the users at the beginning (before Windows,Linux ormacOS arrived).

Today, printing in the console isusedmostly as a monitoring tool, idealto leave a trace of the content of variables during the program execution.
Today, printing in the console is mostlyusedas a monitoringand debuggingtool, idealfor leaving a trace of the content of variables during the program's execution.

This is an example of how to use it:

```py
print("How are you?")
```

## 📝 Instructions:

1. Use `print` to display `"Hello World"` on the console. Feel free to try other things as well.
1. Use `print()` to display `"Hello World"` on the console. Feel free to try other things as well.

## 💡 Hint:

+ :video_camera: You can watch this 5 minutes video about the console:
https://www.youtube.com/watch?v=vROGBvX_MHQ
+ 📹 You can watch this 2 minute video about the console: https://www.youtube.com/watch?v=vROGBvX_MHQ
2 changes: 1 addition & 1 deletionexercises/02-Hello-World/app.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
#your code here
#Your code here
3 changes: 3 additions & 0 deletionsexercises/02-Hello-World/solution.hide.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
# Your code here

print("Hello World")
14 changes: 7 additions & 7 deletionsexercises/03-What-is-a-function/README.es.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
# `03`¿Qué es una función (function)?
# `03`What is afunction?

Puedes ver una función como un **fragmento de código** que puedesencapsular entre llaves para poder usarla varias veces.
Puedes ver una función como un **fragmento de código** que puedesusar varias veces.

Por ejemplo, si queremos obtener la suma de dos números, podemos declarar una función llamada `sum` que devuelve la suma de `number1` y `number2`:

```python
def sum(number1,number2):
return number1 + number2
return number1 + number2
```

Después de declarar la función, podemos usarla tantas veces como queramos, así:
Expand All@@ -15,10 +15,10 @@ Después de declarar la función, podemos usarla tantas veces como queramos, as
total = sum(2,3)
total2 = sum(5,10)

print(total)# imprime 5 en la consola
print(total2)# imprime 15 en la consola
print(total) # Imprime 5 en la consola
print(total2) # Imprime 15 en la consola
```

# 📝 Instrucciones
## 📝 Instrucciones:

1. Calcula la suma entre**3445324** y**53454423** y asigna el resultado a una variable llamada `super_duper`
1. Calcula la suma entre`3445324` y`53454423` y asigna el resultado a una variable llamada `super_duper`.
12 changes: 6 additions & 6 deletionsexercises/03-What-is-a-function/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,19 +10,19 @@ For example: If we want to get the sum of two numbers, we can declare a function

```python
def sum(number1,number2):
return number1 + number2
return number1 + number2
```

After the function is declared we can use it as many times as we want, like this:
After the function is declared, we can use it as many times as we want, like this:

```python
total = sum(2,3)
total2 = sum(5,10)

print(total)# prints 5 on the console
print(total2)# prints 15 on the console
print(total) # Prints 5 on the console
print(total2) # Prints 15 on the console
```

# 📝 Instructions
## 📝 Instructions:

1. Please calculate the sum between**3445324** and**53454423** and assign the result to a variable called `super_duper`
1. Please calculate the sum between`3445324` and`53454423` and assign the result to a variable called `super_duper`.
1 change: 1 addition & 0 deletionsexercises/03-What-is-a-function/app.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
def sum(number1,number2):
return number1 + number2

# Your code here
total = sum(2,3)
print(total)
6 changes: 6 additions & 0 deletionsexercises/03-What-is-a-function/solution.hide.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
def sum(number1,number2):
return number1 + number2

# Your code here
super_duper = sum(3445324,53454423)
print(super_duper)
28 changes: 14 additions & 14 deletionsexercises/04-Call-a-function/README.es.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
---
tutorial: "https://www.youtube.com/watch?v=NU5iW_bWwmY"
---
# `04`Llamando auna función
# `04`Calling aFunction

Una función podría recibir 0 parámetros ytú puedes devolver algo siempre, incluso si no añades explícitamente el `return`.
Una función podría recibir 0 parámetros ydevolverá algo siempre, incluso si no añades explícitamente el `return`.

:point_up: [Presiona aquí para saber más sobre funciones](https://content.breatheco.de/es/lesson/working-with-functions-python/)
👉 [Clic aquí para saber más sobre funciones](https://4geeks.com/es/lesson/working-with-functions-python-es).

Por ejemplo, una función que calcula el área de un cuadrado sería algo como esto:

```python
def calculate_area(length,edge):
return length *edge
def calculate_area(length,width):
return length *width
```

Si deseas usar esa función para calcular el área de un cuadrado con
Si deseas usar esa función para calcular el área de un cuadrado con:

```python
length = 3
edge = 6
width = 6
```

Tendrías que hacer algo como esto:

```python
area = calculate_area(3,6)
# El valordel área es 18
# El valorde 'area' sería 18
```

## 📝 Instrucciones:

1. Crea nuevas variables llamadas `squareArea1`, `square_area2`, `square_area3` y llama a la función `CalculateArea` 3 veces,un por cada cuadrado en la foto, utilizando las dimensiones de la figura, por ejemplo:
1. Crea nuevas variables llamadas `square_area1`, `square_area2`, `square_area3` y llama a la función `calculate_area` 3 veces,una por cada cuadrado en la foto, utilizando las dimensiones de la figura, por ejemplo:

```python
#para la primera figura:
#Para la primera figura:
square_area1 = calculate_area(4,4)
```

![img](http://i.imgur.com/VyoJRAL.png)
![Cuadrados](http://i.imgur.com/VyoJRAL.png)

## 💡Pista:
## 💡Pistas:

- Llama 3 veces a la función `calculate_area`, una por cada cuadrado, pasando la longitud y elborde de cada cuadrado.
- Llama 3 veces a la función `calculate_area`, una por cada cuadrado, pasando la longitud y elancho de cada cuadrado.

+:video_camera: [Video de 9 min sobre funciones en Python](https://www.youtube.com/watch?v=NE97ylAnrz4)
+📹 [Video de 9 min sobre funciones en Python](https://www.youtube.com/watch?v=NE97ylAnrz4).
20 changes: 10 additions & 10 deletionsexercises/04-Call-a-function/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,47 +2,47 @@
tutorial: "https://www.youtube.com/watch?v=NU5iW_bWwmY"
---

# `04` Calling afunction
# `04` Calling aFunction

A function could receive zero parameters, and it always returns something, even if you don't explicitly add the `return` statement.

:point_up: [Click here to read more about functions](https://content.breatheco.de/lesson/working-with-functions-python)
👉 [Click here to read more about functions](https://4geeks.com/lesson/working-with-functions-python).

For example: a function that calculates the area of a square will be something like this:

```python
def calculate_area(length,edge):
return length *edge
def calculate_area(length,width):
return length *width
```

If you want to use that function to calculate the area of a square with:

```python
length = 3
edge = 6
width = 6
```

You need to do something like this:

```python
area = calculate_area(3,6)
# The value of area will be set to 18
# The value of'area' will be set to 18
```

## 📝 Instructions:

1. Createanew variables named `square_area1`, `square_area2`, `square_area3` and call the function `calculate_area` three times one for each square in the picture, for example:
1. Create new variables named `square_area1`, `square_area2`, `square_area3` and call the function `calculate_area` three times, one for each square in the picture, for example:

```python
# For the first figure:
square_area1 = calculate_area(4,4)
```

![img](http://i.imgur.com/VyoJRAL.png)
![Squares](http://i.imgur.com/VyoJRAL.png)

## 💡Hint:
## 💡Hints:

+ Call the `calculate_area` function three times, one per each square, passing the length and edge of each square.

+:video_camera: [9 min video about functions inpython](https://www.youtube.com/watch?v=NE97ylAnrz4)
+📹 [9 min video about functions inPython](https://www.youtube.com/watch?v=NE97ylAnrz4).

6 changes: 3 additions & 3 deletionsexercises/04-Call-a-function/app.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
def calculate_area(length,edge):
return length *edge
def calculate_area(length, width):
return length *width

# Your codeBelow this line:
# Your codebelow this line
8 changes: 4 additions & 4 deletionsexercises/04-Call-a-function/solution.hide.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
def calculate_area(length,edge):
return length *edge
def calculate_area(length, width):
return length *width

# Your codeBelow this line:
# Your codebelow this line
square_area1 = calculate_area(4,4)
square_area2 = calculate_area(2,2)
square_area3 = calculate_area(5,5)
square_area3 = calculate_area(5,5)
8 changes: 4 additions & 4 deletionsexercises/04-Call-a-function/tests.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import io, sys, pytest, os, re, mock

@pytest.mark.it("Createa function 'calculate_area'")
@pytest.mark.it("Createthe function 'calculate_area'")
def test_declare_variable():
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
with open(path, 'r') as content_file:
Expand All@@ -16,7 +16,7 @@ def test_for_callable(capsys, app):
def test_for_integer(capsys, app):
assert isinstance(app.calculate_area(3,4), int)

@pytest.mark.it('We tried the function sum witha=3 andb=4 and it did not return7')
@pytest.mark.it('We tried the function sum withlength=3 andwidth=4 and it did not return12')
def test_for_return(capsys, app):
assert app.calculate_area(3,4) == 12
assert app.calculate_area(5,4) == 20
Expand All@@ -43,10 +43,10 @@ def test_for_square_area_value2(capsys, app):
def test_for_square_area_value3(capsys, app):
assert app.square_area3 == 25

@pytest.mark.it("Create afunction calculate_area must be called 3 times, one for eachfigure")
@pytest.mark.it("Thefunction calculate_area must be called 3 times, one for eachsquare")
def test_call_calculate_area():
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
with open(path, 'r') as content_file:
content = content_file.read()
regex = re.compile(r"=(\s*)calculate_area\s*\(")
assert bool(regex.search(content)) == True
assert bool(regex.search(content)) == True

[8]ページ先頭

©2009-2025 Movatter.jp