Skip to content

Commit 95176e8

Browse files
authored
Merge pull request #93 from josemoracard/jose4-05-user-inputed-values
exercises 05-user-inputed-values to 19-bottles-of-milk
2 parents edd518f + 597414d commit 95176e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+320
-285
lines changed

exercises/05-User-Inputed-Values/README.es.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
Otra cosa genial de las variables es que no necesitas saber su valor para poder trabajar con ellas.
44

5-
Por ejemplo, justo ahora la aplicación está preguntando la edad del usuario, y luego la imprime en la cónsola.
5+
Por ejemplo, justo ahora la aplicación está preguntando la edad del usuario, y luego la imprime en la consola.
66

77
## 📝 Instrucciones:
88

99
1. Por favor, añade 10 años al valor de la variable `age`.
1010

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

1313
+ Puedes buscar en Google "Como sumarle una cantidad a una variable de Python".
1414

15-
+ Recuerda que el contenido de la variable está siendo definido con lo que sea que el usuario coloque.
15+
+ Recuerda que el contenido de la variable está siendo definido con lo que sea que el usuario coloque.

exercises/05-User-Inputed-Values/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ For example, the application right now is prompting the user for its age, and th
1212

1313
1. Please add 10 years to the value of the age variable.
1414

15-
## 💡Hint
15+
## 💡 Hints:
1616

17-
+ You can Google "how to add a number to a python variable".
17+
+ You can Google "how to add a number to a Python variable".
1818

19-
+ Remember that the content of the variable its being previously filled with whatever the user inputs.
19+
+ Remember that the content of the variable is being previously filled with whatever the user inputs.

exercises/05-User-Inputed-Values/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def test_for_file_output(capsys):
99
regex = re.compile(pattern)
1010
assert bool(regex.search(content)) == True
1111

12-
@pytest.mark.it("We tried with age 50 and it was supposed to return 60")
12+
@pytest.mark.it("Testing with age 50 and it is supposed to return 60")
1313
@mock.patch('builtins.input', lambda x: 50)
1414
def test_plus_ten(stdin):
1515
# f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')

exercises/06-String-Concatenation/README.es.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ Puedes pensar en este proceso como conectar dos o más vagones de tren. Si cada
77
En Python, puedes concatenar o unir dos o más strings usando el operador `+`. Así es como funciona:
88

99
```py
10-
1110
one = 'a'
1211
two = 'b'
13-
print(one + two) # esto imprimirá 'ab' en la consola.
12+
print(one + two) # Esto imprimirá 'ab' en la consola.
1413
```
1514

1615
Aquí, las variables `one` y `two` contienen los strings individuales `'a'` y `'b'`, respectivamente. Cuando usas el operador `+` entre ellos, actúa como un pegamento, uniendo los strings de extremo a extremo. En este caso, une `'a'` y `'b'`, dando como resultado el string concatenado `'ab'`, que se imprime en la consola.
@@ -20,4 +19,4 @@ Aquí, las variables `one` y `two` contienen los strings individuales `'a'` y `'
2019

2120

2221
## 💡 Pista:
23-
+ Si necesitas más explicación sobre como la **concatenación** funciona en Python, puedes ver este clip: https://www.youtube.com/watch?v=T1nyPuAhd1U&ab_channel=ProgramaResuelto (`ctrl + click` en el enlance para abrir el video)
22+
+ Si necesitas más explicación sobre como funciona la **concatenación** en Python, puedes ver este clip: https://www.youtube.com/watch?v=T1nyPuAhd1U&ab_channel=ProgramaResuelto (`ctrl + click` en el enlace para abrir el video)

exercises/06-String-Concatenation/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ You can think of this process as similar to connecting two or more train cars. I
1111
In Python, you can concatenate, or join together, two or more strings using the `+` operator. This is how it works:
1212

1313
```py
14-
1514
one = 'a'
1615
two = 'b'
17-
print(one + two) # this will print 'ab' on the console.
16+
print(one + two) # This will print 'ab' on the console.
1817
```
1918

2019
Here, the variables `one` and `two` hold the individual strings `'a'` and `'b'`. When you use the `+` operator between them, it acts like a glue, sticking the strings together end-to-end. In this case, it joins `'a'` and `'b'`, resulting in the concatenated string `'ab'`, which gets printed to the console.
2120

2221
## 📝 Instructions:
23-
1. Set the values for `my_var1` and `my_var2` so that when concatenated, the code prints `Hello World` in the console.
22+
1. Set the values for `my_var1` and `my_var2` so that, when concatenated, the code prints `Hello World` in the console.
2423

2524
## 💡 Hint:
26-
+ If you need further explanation on how string **concatenation** works in python, you can watch this clip: https://www.youtube.com/watch?v=28FUVmWU_fA&ab_channel=PortfolioCourses (`ctrl + click` on the link to open the video)
25+
+ If you need further explanation on how string **concatenation** works in Python, you can watch this clip: https://www.youtube.com/watch?v=28FUVmWU_fA&ab_channel=PortfolioCourses (`ctrl + click` on the link to open the video)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ✅ ↓ Set the values for my_var1 and my_var2 here ↓ ✅
22

33

4-
## Don't change below this line
5-
the_new_string = my_var1+' '+my_var2
6-
print(the_new_string)
4+
## Don't change anything below this line
5+
the_new_string = my_var1 + ' ' + my_var2
6+
print(the_new_string)

exercises/06-String-Concatenation/solution.hide.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
my_var1 = "Hello"
44
my_var2 = "World"
55

6-
## Don't change below this line
7-
the_new_string = my_var1+' '+my_var2
8-
print(the_new_string)
6+
## Don't change anything below this line
7+
the_new_string = my_var1 + ' ' + my_var2
8+
print(the_new_string)

exercises/06-String-Concatenation/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_my_var2_value():
2727
from app import my_var2
2828
assert my_var2.lower() == "world"
2929

30-
@pytest.mark.it("Variable my_var2 value should be 'World'")
30+
@pytest.mark.it("Don't remove the_new_string variable")
3131
def test_the_new_string_exists():
3232
import app
3333
try:
@@ -38,4 +38,4 @@ def test_the_new_string_exists():
3838
@pytest.mark.it('Print "Hello World" on the console')
3939
def test_for_file_output():
4040
captured = buffer.getvalue()
41-
assert "hello world\n" in captured.lower() #add \n because the console jumps the line on every print
41+
assert "hello world\n" in captured.lower() #add \n because the console jumps the line on every print

exercises/07-Create-a-Basic-HTML/README.es.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@ Continuemos concatenando strings para generar un documento HTML básico...
44

55
## 📝 Instrucciones:
66

7-
1. Crea una variable **html_document**.
7+
1. Crea la variable `html_document`.
88

9-
2. El código a la izquierda contiene 8 variables con diferentes valores de tipo *string*. Por favor, usa las variables concatenándolas entre ellas para establecer el valor de la variable **html_document** como nuevo string que tenga el contenido de un documento HTML típico (con las etiquetas HTML
10-
en el orden correcto).
9+
2. El código a la izquierda contiene 8 variables con diferentes valores de tipo *string*. Por favor, usa las variables concatenándolas entre ellas para establecer el valor de la variable `html_document` a la estructura típica de un documento HTML (con las etiquetas HTML en el orden correcto).
1110

12-
3. Luego, imprime el valor de **html_document** en la consola.
11+
3. Luego, imprime el valor de `html_document` en la consola.
1312

1413
## 💡 Pista:
1514

1615
+ Resultado esperado:
1716

18-
```sh
19-
17+
```html
2018
<html><head><title></title></head><body></body></html>
2119
```
2220

exercises/07-Create-a-Basic-HTML/README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,24 @@
22
tutorial: "https://www.youtube.com/watch?v=j14V-eS8mRg"
33
---
44

5-
# `07` Create a basic HTML
5+
# `07` Create a Basic HTML
66

77
Let's continue using string concatenation to generate HTML...
88

99
## 📝 Instructions:
1010

11-
1. Create a variable **html_document**.
11+
1. Create the variable `html_document`.
1212

13-
2. The code on the left contains 8 variables with different string values, please use the variables concatenating them together to set the value of the variable **html_document**
14-
a new string that has the content of a typical HTML document (with the HTML tags in the
15-
right order).
13+
2. The code on the left contains 8 variables with different string values, please use the variables concatenating them together to set the value of the variable `html_document`
14+
to a new string that has the content of a typical HTML document (with the HTML tags in the right order).
1615

17-
3. Then, print the value of **html_document** on the console.
16+
3. Then, print the value of `html_document` on the console.
1817

1918
## 💡 Hint:
2019

2120
+ Expected Result:
2221

23-
```sh
24-
22+
```html
2523
<html><head><title></title></head><body></body></html>
2624
```
2725

exercises/07-Create-a-Basic-HTML/solution.hide.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111

1212
# ✅ ↓ start coding below here ↓ ✅
1313

14-
html_document = e+c+g+a+f+h+d+b
15-
print(html_document)
14+
html_document = e + c + g + a + f + h + d + b
15+
print(html_document)

exercises/08.1-Your-First-If/README.es.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ La aplicación actual está preguntando cuánto dinero tiene el usuario. Una vez
44

55
## 📝 Instrucciones:
66

7-
1. Si el usuario tiene más de $100, respondemos: "Give me your money!" (Dame tu dinero).
7+
1. Si el usuario tiene más de $100, respondemos: "Give me your money!" (¡Dame tu dinero!).
88

9-
2. Si el usuario tiene más de $50, respondemos: "Buy me some coffee you cheap!" (¡Comprame un café!).
9+
2. Si el usuario tiene más de $50, respondemos: "Buy me some coffee, you cheap!" (¡Cómprame un café!).
1010

1111
3. Si el usuario tiene igual o menos de $50, respondemos: "You are a poor guy, go away!" (¡Eres pobre!).
1212

13-
## 💡 Pista:
13+
## 💡 Pistas:
1414

15-
+ Usa un condicional `if/else` para verificar el valor de la variable `total`.
15+
+ Usa un condicional `if...else` para verificar el valor de la variable `total`.
1616

1717
+ Puedes leer más al respecto [aquí](https://docs.python.org/3/tutorial/controlflow.html#if-statements).
1818

1919
+ Aquí tienes un recordatorio sobre los operadores relacionales:
2020

2121
| Operador | Descripción | Sintaxis |
2222
|----------|------------------------------------------------------------------------------|----------|
23-
| > | Mayor que: Verdadero si el operando izquierdo es mayor que el derecho | x > y |
24-
| < | Menor que: Verdadero si el operando izquierdo es menor que el derecho | x < y |
25-
| == | Igual a: Verdadero si ambos operandos son iguales | x == y |
26-
| != | No igual a – Verdadero si los operandos no son iguales | x != y |
27-
| >= | Mayor o igual que: Verdadero si el operando izquierdo es mayor o igual | x >= y |
28-
| <= | Menor o igual que: Verdadero si el operando izquierdo es menor o igual | x <= y |
23+
| > | Mayor que: True si el operando izquierdo es mayor que el derecho | x > y |
24+
| < | Menor que: True si el operando izquierdo es menor que el derecho | x < y |
25+
| == | Igual a: True si ambos operandos son iguales | x == y |
26+
| != | No igual a: True si los operandos no son iguales | x != y |
27+
| >= | Mayor o igual que: True si el operando izquierdo es mayor o igual | x >= y |
28+
| <= | Menor o igual que: True si el operando izquierdo es menor o igual | x <= y |

exercises/08.1-Your-First-If/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22
tutorial: "https://www.youtube.com/watch?v=x9wqa5WQZiM"
33
---
44

5-
# `08.1` Your First if...
5+
# `08.1` Your First If...
66

77
The current application is asking how much money the user has. Once the user inputs the amount, we need to **print** one of the following answers:
88

99
## 📝 Instructions:
1010

1111
1. If the user has more than $100, we answer: "Give me your money!".
1212

13-
2. If the user has more than $50, we answer: "Buy me some coffee you cheap!".
13+
2. If the user has more than $50, we answer: "Buy me some coffee, you cheap!".
1414

15-
3. If the user has less or equal than $50, we answer: "You are a poor guy, go away!".
15+
3. If the user has less than or equal to $50, we answer: "You are a poor guy, go away!".
1616

17-
## 💡 Hint:
17+
## 💡 Hints:
1818

19-
+ Use an If/else statement to check the value of the `total` variable.
19+
+ Use an `if...else` statement to check the value of the `total` variable.
2020

2121
+ Further information [here](https://docs.python.org/3/tutorial/controlflow.html#if-statements).
2222

2323
+ Here's a quick reminder on relational operators:
2424

25-
| Operator | Description | Syntax |
26-
|----------|--------------------------------------------------------------------|-----------|
27-
| > | Greater than: True if the left operand is greater than the right | x > y |
28-
| < | Less than: True if the left operand is less than the right | x < y |
29-
| == | Equal to: True if both operands are equal | x == y |
30-
| != | Not equal toTrue if operands are not equal | x != y |
31-
| >= | Greater than or equal to: True if left operand is greater or equal | x >= y |
32-
| <= | Less than or equal to: True if left operand is less than or equal | x <= y |
25+
| Operator | Description | Syntax |
26+
|----------|------------------------------------------------------------------------|-----------|
27+
| > | Greater than: True if the left operand is greater than the right | x > y |
28+
| < | Less than: True if the left operand is less than the right | x < y |
29+
| == | Equal to: True if both operands are equal | x == y |
30+
| != | Not equal to: True if operands are not equal | x != y |
31+
| >= | Greater than or equal to: True if the left operand is greater or equal | x >= y |
32+
| <= | Less than or equal to: True if the left operand is less or equal | x <= y |

exercises/08.1-Your-First-If/solution.hide.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
if total > 100:
55
print("Give me your money!")
66
elif total > 50:
7-
print("Buy me some coffee you cheap!")
7+
print("Buy me some coffee, you cheap!")
88
else:
9-
print("You are a poor guy, go away!")
9+
print("You are a poor guy, go away!")

exercises/08.1-Your-First-If/test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,37 +31,37 @@ def test_for_output_when_101(stdin, capsys, app):
3131
captured = capsys.readouterr()
3232
assert "Give me your money!\n" in captured.out
3333

34-
@pytest.mark.it("When input exactly 100 should print: Buy me some coffee you cheap ")
34+
@pytest.mark.it("When input exactly 100 should print: Buy me some coffee, you cheap!")
3535
def test_for_output_when_100(capsys, app):
3636
with mock.patch('builtins.input', lambda x: 100):
3737
app()
3838
captured = capsys.readouterr()
39-
assert "Buy me some coffee you cheap!\n" in captured.out
39+
assert "Buy me some coffee, you cheap!\n" in captured.out
4040

41-
@pytest.mark.it("When input is 99 should print: Buy me some coffee you cheap ")
41+
@pytest.mark.it("When input is 99 should print: Buy me some coffee, you cheap!")
4242
def test_for_output_when_99(capsys, app):
4343
with mock.patch('builtins.input', lambda x: 99):
4444
app()
4545
captured = capsys.readouterr()
46-
assert "Buy me some coffee you cheap!\n" in captured.out
46+
assert "Buy me some coffee, you cheap!\n" in captured.out
4747

48-
@pytest.mark.it("When input is 51 should print: Buy me some coffee you cheap ")
48+
@pytest.mark.it("When input is 51 should print: Buy me some coffee, you cheap!")
4949
def test_for_output_when_51(capsys, app):
5050
with mock.patch('builtins.input', lambda x: 51):
5151
app()
5252
captured = capsys.readouterr()
53-
assert "Buy me some coffee you cheap!\n" in captured.out
53+
assert "Buy me some coffee, you cheap!\n" in captured.out
5454

55-
@pytest.mark.it("When input exactly 50 should print: You are a poor guy, go away")
55+
@pytest.mark.it("When input exactly 50 should print: You are a poor guy, go away!")
5656
def test_for_output_when_50(capsys, app):
5757
with mock.patch('builtins.input', lambda x: 50):
5858
app()
5959
captured = capsys.readouterr()
6060
assert "You are a poor guy, go away!\n" in captured.out
6161

62-
@pytest.mark.it("When input less than 50 should print: You are a poor guy, go away")
62+
@pytest.mark.it("When input less than 50 should print: You are a poor guy, go away!")
6363
def test_for_output_when_49(capsys, app):
6464
with mock.patch('builtins.input', lambda x: 49):
6565
app()
6666
captured = capsys.readouterr()
67-
assert "You are a poor guy, go away!\n" in captured.out
67+
assert "You are a poor guy, go away!\n" in captured.out
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `08.2` Cuánto costará la boda (if...else)
1+
# `08.2` How Much The Wedding Costs (if...else)
22

33
Aquí tenemos una tabla de precios de una compañía de catering de bodas:
44

@@ -9,16 +9,16 @@ Aquí tenemos una tabla de precios de una compañía de catering de bodas:
99
| Hasta 200 personas | $15,000 |
1010
| Más de 200 personas | $20,000 |
1111

12-
>Nota: Las cantidades en la tabla incluyen el número especificado. Por ejemplo, "Hasta 50 personas" incluye exactamente 50 personas.
12+
> Nota: Las cantidades en la tabla incluyen el número especificado. Por ejemplo, "Hasta 50 personas" incluye exactamente 50 personas.
1313
1414
## 📝 Instrucciones:
1515

1616
1. Completa el algoritmo que solicita al usuario el número de personas que asistirán a su boda e imprime el precio correspondiente en la consola.
1717
2. Amplía el código proporcionado a la izquierda para cubrir todos los rangos posibles de invitados.
1818
3. Asegúrate de que tu código calcule e imprima correctamente el precio en la consola según el input del usuario.
1919

20-
Por ejemplo, si la persona dice que `20` personas van a la boda, deberìa costar `$4,000` dólares.
20+
Por ejemplo, si la persona dice que `20` personas van a la boda, debería costar `$4,000` dólares.
2121

2222
## 💡 Pista:
2323

24-
+ Usa if/else para dividir el código y definir el valor de la variable `price` de forma correcta.
24+
+ Usa `if...else` para dividir el código y definir el valor de la variable `price` de forma correcta.

exercises/08.2-How-Much-The-Wedding-Costs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ For example, if the user says that `20` people are attending to the wedding, it
2525

2626
## 💡 Hint:
2727

28-
+ Use if/else to divide your code and set the value of the `price` variable the right way.
28+
+ Use `if...else` to divide your code and set the value of the `price` variable the right way.

exercises/08.2-How-Much-The-Wedding-Costs/test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def test_for_print(capsys):
1616
regex2 = re.compile(r"elif\s*")
1717
assert bool(regex2.search(content)) == True
1818

19+
1920
@pytest.mark.it("Between 101 and 200 guests sould be priced 15,000")
2021
def test__between_100_and_200(capsys, app):
2122
with mock.patch('builtins.input', lambda x: 200):
@@ -24,6 +25,7 @@ def test__between_100_and_200(capsys, app):
2425
price = 15000
2526
assert "Your wedding will cost "+str(price)+" dollars\n" in captured.out
2627

28+
2729
@pytest.mark.it("Between 51 and 100 guests sould be priced 10,000")
2830
def test_between_101_and_51(capsys, app):
2931
with mock.patch('builtins.input', lambda x: 100):
@@ -33,18 +35,18 @@ def test_between_101_and_51(capsys, app):
3335
assert "Your wedding will cost "+str(price)+" dollars\n" in captured.out
3436

3537

36-
@pytest.mark.it("Less than 50 guests sould be priced 4,000")
38+
@pytest.mark.it("Less than 50 guests, it should cost 4,000")
3739
def test_less_than_50(capsys, app):
3840
with mock.patch('builtins.input', lambda x: 50):
3941
app()
4042
captured = capsys.readouterr()
4143
price = 4000
4244
"Your wedding will cost "+str(price)+" dollars\n" in captured.out
4345

44-
@pytest.mark.it("More than 200 should be priced 20,000")
46+
@pytest.mark.it("More than 200 guests, it should cost 20,000")
4547
def test_t(capsys, app):
4648
with mock.patch('builtins.input', lambda x: 201):
4749
app()
4850
captured = capsys.readouterr()
4951
price = 20000
50-
"Your wedding will cost "+str(price)+" dollars\n" in captured.out
52+
"Your wedding will cost "+str(price)+" dollars\n" in captured.out

0 commit comments

Comments
 (0)