Skip to content

Commit 6c40b2f

Browse files
authored
Merge pull request #55 from josemoracard/jose5-017-total_cost
exercises 017-total_cost to 23-list_and_tuple
2 parents 5b6aa9b + 5a61d9c commit 6c40b2f

28 files changed

+228
-151
lines changed

exercises/017-total_cost/README.es.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22

33
## 📝 Instrucciones:
44

5-
1. Un cupcake (quequito) cuesta `D` dólares y `C` centavos. Escribe un función `total_cost()` para determinar cuántos dólares y centavos debería pagar una persona por `N` cupcakes. *La función recibe tres números: `D`, `C`, `N` y debería devolver dos números: costo total en dólares y los centavos*
5+
1. Un cupcake cuesta `d` dólares y `c` centavos. Escribe una función `total_cost()` para determinar cuántos dólares y centavos debería pagar una persona por `n` cupcakes. *La función recibe tres números: `d`, `c`, `n` y debería devolver dos números: costo total en dólares y centavos*
66

7-
## Ejemplo de entrada:
7+
## 📎 Ejemplo de entrada:
88

99
```py
1010
total_cost(10,15,2)
1111
```
1212

13-
## Ejemplo de salida:
13+
## 📎 Ejemplo de salida:
1414

15-
+ (20, 30)
15+
```py
16+
(20, 30)
17+
```
1618

1719
## 💡 Pistas:
1820

1921
+ Si no sabes por donde comenzar este ejercicio, por favor, revisa la teoría en esta lección: https://snakify.org/lessons/integer_float_numbers/
2022

21-
+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/
23+
+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/

exercises/017-total_cost/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22

33
## 📝 Instructions:
44

5-
1. A cupcake costs `D` dollars and `C` cents. Write a function that determines how many dollars and cents should someone pay for `N` cupcakes. *The function gets three numbers: `D`, `C`, `N` and it should return two numbers: total cost in dollars and cents.*
5+
1. A cupcake costs `d` dollars and `c` cents. Write a function that determines how many dollars and cents someone should pay for `n` cupcakes. *The function gets three numbers: `d`, `c`, `n` and it should return two numbers: total cost in dollars and cents.*
66

7-
## Example input:
7+
## 📎 Example input:
88

99
```py
1010
total_cost(10,15,2)
1111
```
1212

13-
## Example output:
13+
## 📎 Example output:
1414

15-
+ (20, 30)
15+
```py
16+
(20, 30)
17+
```
1618

1719
## 💡 Hints:
1820

19-
+ If you don't know how to start solving this assignment, please, review a theory for this lesson: https://snakify.org/lessons/integer_float_numbers/
21+
+ If you don't know how to start solving this assignment, please review the theory for this lesson: https://snakify.org/lessons/integer_float_numbers/
2022

2123
+ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/

exercises/017-total_cost/app.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
#Complete the function to return the total cost in dollars and cents of N cupcakes.
2-
#Remember you can return multiple parameters => return a, b
3-
def total_cost(d,c,n):
1+
# Complete the function to return the total cost in dollars and cents of (n) cupcakes
2+
def total_cost(d, c, n):
43
return None
5-
64

75

8-
9-
#Invoke the function with three intergers: cost(dollars and cents) & number of cupcakes.
10-
print(total_cost())
6+
# Invoke the function with three integers: total_cost(dollars, cents, number_of_cupcakes)
7+
print(total_cost(15,22,4))
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#Complete the function to return the total cost in dollars and cents of N cupcakes.
2-
#Remember you can return multiple parameters => return a, b
3-
def total_cost(d,c,n):
4-
return ((((d*100)+c)*n)//100, (((d*100)+c)*n)%100)
5-
1+
# Complete the function to return the total cost in dollars and cents of (n) cupcakes
2+
def total_cost(d, c, n):
3+
total_cents = (d * 100 + c) * n
4+
total_dollars = total_cents // 100
5+
remaining_cents = total_cents % 100
6+
return total_dollars, remaining_cents
67

78

8-
9-
#Invoke the function with three intergers: cost(dollars and cents) & number of cupcakes.
9+
# Invoke the function with three integers: total_cost(dollars, cents, number_of_cupcakes)
1010
print(total_cost(15,22,4))

exercises/017-total_cost/test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def test_function_return_type_parameters(capsys, app):
1919
result = app.total_cost(15, 22, 4)
2020
assert type(result[0]) == type(1) and type(result[1]) == type(1)
2121

22-
@pytest.mark.it('We tried to pass 15, 22, 4 as parameters and it did not return (60, 88)!')
22+
@pytest.mark.it('We tried to pass 15, 22, 4 as parameters and it did not return (60, 88)')
2323
def test_for_file_output(capsys, app):
2424
assert app.total_cost(15, 22, 4) == (60, 88)
2525

26-
@pytest.mark.it('We tried to pass 10, 15, 4 as parameters and it did not return (20, 30)!')
26+
@pytest.mark.it('We tried to pass 10, 15, 4 as parameters and it did not return (40, 60)')
2727
def test_for_file_output2(capsys, app):
28-
assert app.total_cost(15, 22, 4) == (60, 88)
28+
assert app.total_cost(10, 15, 4) == (40, 60)
2929

exercises/018-day_of_week/README.es.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,31 @@
22

33
## 📝 Instrucciones:
44

5-
1. Escribe una función `day_of_week()`. Dado un entero `K` en el rango comprendido entre [1, 365], `day_of_week()` encuentra el número del día de la semana para el k-ésimo día del año si este año el 1 de enero fue jueves.
5+
1. Escribe una función `day_of_week()`. Dado un entero `k` en el rango comprendido entre 1 a 365, `day_of_week()` encuentra el número del día de la semana para el k-ésimo día del año si este año el 1 de enero fue jueves.
66

77
*Los días de la semana se enumeran así:*
88

9+
```text
910
0 — Domingo
1011
1 — Lunes
1112
2 — Martes, ...
12-
6 — Sábado.
13+
6 — Sábado
14+
```
1315

14-
## Ejemplo de entrada:
16+
## 📎 Ejemplo de entrada:
1517

1618
```py
1719
day_of_week(1)
1820
```
1921

20-
## Ejemplo de salida:
22+
## 📎 Ejemplo de salida:
2123

22-
+ 4
24+
```py
25+
4
26+
```
2327

2428
## 💡 Pistas:
2529

2630
+ Si no sabes por donde comenzar este ejercicio, por favor, revisa la teoría en esta lección: https://snakify.org/lessons/integer_float_numbers/
2731

28-
+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/
32+
+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/

exercises/018-day_of_week/README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,31 @@
22

33
## 📝 Instructions:
44

5-
1. Write a function `day_of_week()`. Given an integer `K` in the range 1 to 365 is given, `day_of_week()` finds the number of day of week for K-th day of year provided that in this year January 1 was Thursday.
5+
1. Write a function `day_of_week()`. Given an integer `k` in the range 1 to 365, `day_of_week()` finds the number of day of week for *k-th* day of the year, provided that in this year January 1 was Thursday.
66

7-
*Days of week are numbered as:*
7+
*The days of the week are numbered as:*
88

9+
```text
910
0 — Sunday
1011
1 — Monday
1112
2 — Tuesday, ...
12-
6 — Saturday.
13+
6 — Saturday
14+
```
1315

14-
## Example input:
16+
## 📎 Example input:
1517

1618
```py
1719
day_of_week(1)
1820
```
1921

20-
## Example output:
22+
## 📎 Example output:
2123

22-
+ 4
24+
```py
25+
4
26+
```
2327

2428
## 💡 Hints:
2529

26-
+ If you don't know how to start solving this assignment, please, review a theory for this lesson: https://snakify.org/lessons/integer_float_numbers/
30+
+ If you don't know how to start solving this assignment, please review the theory for this lesson: https://snakify.org/lessons/integer_float_numbers/
2731

28-
+ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/
32+
+ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/

exercises/018-day_of_week/app.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
#Complete the function to return the number of day of the week for k'th day of year.
1+
# Complete the function to return the number of day of the week for k'th day of year
22
def day_of_week(k):
3-
43
return None
54

65

7-
8-
#Invoke function day_of_week with an interger between 0 and 6 (number for days of week)
9-
print(day_of_week())
6+
# Invoke function day_of_week with an integer between 1 and 365
7+
print(day_of_week())
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
#Complete the function to return the number of day of the week for k'th day of year.
1+
# Complete the function to return the number of day of the week for k'th day of year
22
def day_of_week(k):
3-
4-
return (3+k)%7
3+
return (3 + k) % 7
54

65

7-
8-
#Invoke function day_of_week with an interger between 0 and 6 (number for days of week)
9-
print(day_of_week(1))
6+
# Invoke function day_of_week with an integer between 1 and 365
7+
print(day_of_week(125))

exercises/018-day_of_week/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def test_function_return(capsys, app):
1414
def test_function_return_type(capsys, app):
1515
assert type(app.day_of_week(1)) == type(1)
1616

17-
@pytest.mark.it('Something went wrong! We tried to pass 1 as parameter and it did not return 4! Keep trying!')
17+
@pytest.mark.it('Something went wrong! We tried to pass 1 as parameter and it did not return 4. Keep trying!')
1818
def test_for_file_output(capsys, app):
1919
assert app.day_of_week(1) == 4
2020

21-
@pytest.mark.it('Something went wrong! We tried to pass 46 as parameter and it did not return 4! Keep trying!')
21+
@pytest.mark.it('Something went wrong! We tried to pass 46 as parameter and it did not return 0. Keep trying!')
2222
def test_for_file_output2(capsys, app):
2323
assert app.day_of_week(46) == 0
2424

exercises/019-digital_clock/README.es.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@
22

33
## 📝 Instrucciones:
44

5-
1. Dado un entero `N` que representa el número de minutos han pasado desde media noche, ¿cuántas horas y minutos se han mostrado en un reloj digital con formato 24 horas? Escribe una función `digital_clock()` para calcularlo. *La función debería imprimir dos números: el número de horas (entre 0 y 23) y el número de minutos (entre 0 y 59).*
5+
1. Dado un entero `n` que representa el número de minutos que han pasado desde media noche, ¿cuántas horas y minutos se mostrarían en un reloj digital con formato 24 horas? Escribe una función `digital_clock()` para calcularlo. *La función debería imprimir dos números: el número de horas (entre 0 y 23) y el número de minutos (entre 0 y 59).*
66

7-
## Ejemplo de entrada:
7+
## 📎 Ejemplo de entrada:
88

99
```py
1010
digital_clock(150)
1111
```
1212

13-
## Ejemplo de salida:
13+
## 📎 Ejemplo de salida:
1414

15-
+ (2, 30)
15+
```py
16+
(2, 30)
17+
```
1618

17-
Por ejemplo, si N = 150, entonces son 150 minutos que han pasado desde medianoche. Es decir, ahora son las 2:30 am, así que la función debería imprimir 2 30.
19+
Por ejemplo, si n = 150, entonces son 150 minutos que han pasado desde medianoche. Es decir, ahora son las 2:30 am, así que la función debería imprimir (2, 30).
1820

1921
## 💡 Pistas:
2022

2123
+ Si no sabes por donde comenzar este ejercicio, por favor, revisa la teoría en esta lección: https://snakify.org/lessons/integer_float_numbers/
2224

23-
+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/
25+
+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/

exercises/019-digital_clock/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@
22

33
## 📝 Instructions:
44

5-
1. Given the integer `N` - the number of minutes that is passed since midnight. How many hours and minutes are displayed on the 24h digital clock? Write a `digital_clock()` function to calculate it. *The function should print two numbers: the number of hours (between 0 and 23) and the number of minutes (between 0 and 59).*
5+
1. Given the integer `n` - the number of minutes that have passed since midnight, how many hours and minutes are displayed on the 24h digital clock? Write a `digital_clock()` function to calculate it. *The function should print two numbers: the number of hours (between 0 and 23) and the number of minutes (between 0 and 59).*
66

7-
## Example input:
7+
## 📎 Example input:
88

99
```py
1010
digital_clock(150)
1111
```
1212

13-
## Example output:
13+
## 📎 Example output:
1414

15-
+ (2, 30)
15+
```py
16+
(2, 30)
17+
```
1618

17-
For example, if N = 150, then 150 minutes have passed since midnight - i.e. now is 2:30 am. So the function should print 2 30.
19+
For example, if n = 150, then 150 minutes have passed since midnight - i.e. now is 2:30 am. So the function should print (2, 30).
1820

1921
## 💡 Hints:
2022

21-
+ If you don't know how to start solving this assignment, please, review a theory for this lesson: https://snakify.org/lessons/integer_float_numbers/
23+
+ If you don't know how to start solving this assignment, please review the theory for this lesson: https://snakify.org/lessons/integer_float_numbers/
2224

23-
+ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/
25+
+ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/

exercises/019-digital_clock/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Complete the function to return how many hrs and min are displayed on the 24th digital clock.
1+
# Complete the function to return how many hours and minutes are displayed on the 24h digital clock
22
def digital_clock(n):
33
return None
44

5-
#Invoke the function with any interger (seconds after midnight)
5+
# Invoke the function with any integer (minutes after midnight)
66
print(digital_clock())
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Complete the function to return how many hrs and min are displayed on the 24th digital clock.
1+
# Complete the function to return how many hours and minutes are displayed on the 24h digital clock
22
def digital_clock(n):
33
return ((n // 60), (n % 60))
44

5-
#Invoke the function with any interger (seconds after midnight)
5+
# Invoke the function with any integer (minutes after midnight)
66
print(digital_clock(150))

exercises/019-digital_clock/test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def test_function_return(capsys, app):
1414
def test_function_return_type(capsys, app):
1515
assert type(app.digital_clock(194)) == type((3, 14))
1616

17-
@pytest.mark.it('We tried to pass 194 as parameter and it did not return (3, 14)!Keep Trying!')
17+
@pytest.mark.it('We tried to pass 194 as parameter and it did not return (3, 14). Keep Trying!')
1818
def test_for_file_output(capsys, app):
1919
assert app.digital_clock(194) == (3, 14)
2020

21-
@pytest.mark.it('We tried to pass 150 as parameter and it did not return (2, 50)! Keep Trying!')
21+
@pytest.mark.it('We tried to pass 150 as parameter and it did not return (2, 30). Keep Trying!')
2222
def test_for_file_output(capsys, app):
23-
assert app.digital_clock(150) == (2,30)
23+
assert app.digital_clock(150) == (2, 30)
2424

exercises/020-factorial/README.es.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
## 📝 Instrucciones:
44

5-
1. Crea una función llamada `factorial()` que al recibir un número como parámatro retorne su valor factorial.
5+
1. Crea una función llamada `factorial()`, que al recibir un número como parámetro retorne su valor factorial.
66

7-
## Ejemplo de entrada:
7+
## 📎 Ejemplo de entrada:
88

99
```py
1010
factorial(8)
1111
```
1212

13-
## Ejemplo de salida:
13+
## 📎 Ejemplo de salida:
1414

15-
+ 40320
15+
```py
16+
40320
17+
```
1618

1719
## 💡 Pista:
1820

exercises/020-factorial/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
## 📝 Instructions:
44

5-
1. Create a function named `factorial()` which receives a number as parameter and returns the factorial of the given number.
5+
1. Create a function named `factorial()`, which receives a number as a parameter and returns the factorial of the given number.
66

7-
## Example input:
7+
## 📎 Example input:
88

99
```py
1010
factorial(8)
1111
```
1212

13-
## Example output:
13+
## 📎 Example output:
1414

15-
+ 40320
15+
```py
16+
40320
17+
```
1618

1719
## 💡 Hint:
1820

0 commit comments

Comments
 (0)