Skip to content

exercises 017-total_cost to 23-list_and_tuple #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
merged 55 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
92fa21b
Update README.md
josemoracard Dec 13, 2023
3d6e983
Update README.md
josemoracard Dec 13, 2023
5cf63c0
Update README.es.md
josemoracard Dec 13, 2023
36a59be
Update app.py
josemoracard Dec 13, 2023
956415c
Update solution.hide.py
josemoracard Dec 13, 2023
d54fd70
Update solution.hide.py
josemoracard Dec 13, 2023
2876b1d
Update solution.hide.py
josemoracard Dec 13, 2023
d829bc3
Update app.py
josemoracard Dec 13, 2023
821e65f
Update README.md
josemoracard Dec 13, 2023
83d131c
Update README.es.md
josemoracard Dec 13, 2023
13ad9fc
Update test.py
josemoracard Dec 13, 2023
4062a1d
Update test.py
josemoracard Dec 13, 2023
908c3a3
Update README.md
josemoracard Dec 13, 2023
e95216c
Update README.md
josemoracard Dec 13, 2023
fc98fac
Update README.md
josemoracard Dec 13, 2023
9b16096
Update README.es.md
josemoracard Dec 13, 2023
5c87791
Update app.py
josemoracard Dec 13, 2023
2a330b6
Update solution.hide.py
josemoracard Dec 13, 2023
234463c
Update README.md
josemoracard Dec 13, 2023
35d140c
Update README.md
josemoracard Dec 13, 2023
8abd13e
Update README.es.md
josemoracard Dec 13, 2023
8c8b0f3
Update test.py
josemoracard Dec 13, 2023
50c7934
Update app.py
josemoracard Dec 13, 2023
9120dcc
Update solution.hide.py
josemoracard Dec 13, 2023
5fb74a7
Update solution.hide.py
josemoracard Dec 13, 2023
ca891c1
Update README.md
josemoracard Dec 13, 2023
2e26744
Update README.es.md
josemoracard Dec 13, 2023
a086e8c
Update app.py
josemoracard Dec 13, 2023
4e9319c
Update solution.hide.py
josemoracard Dec 13, 2023
cb5b4c4
Update test.py
josemoracard Dec 13, 2023
08aa679
Update README.md
josemoracard Dec 13, 2023
133efc6
Update README.md
josemoracard Dec 13, 2023
18f9426
Update README.es.md
josemoracard Dec 13, 2023
f63d74b
Update solution.hide.py
josemoracard Dec 13, 2023
b6be5f9
Update test.py
josemoracard Dec 13, 2023
77bb109
Update README.md
josemoracard Dec 13, 2023
1f0cf7a
Update README.md
josemoracard Dec 13, 2023
9b859b4
Update README.es.md
josemoracard Dec 13, 2023
475fc38
Update app.py
josemoracard Dec 13, 2023
ad47096
Update solution.hide.py
josemoracard Dec 13, 2023
fa43a77
Update test.py
josemoracard Dec 13, 2023
2ede745
Update README.es.md
josemoracard Dec 13, 2023
76866fb
Update README.md
josemoracard Dec 13, 2023
08fd69e
Update README.md
josemoracard Dec 13, 2023
959417c
Update README.md
josemoracard Dec 13, 2023
1a9c65c
Update README.es.md
josemoracard Dec 13, 2023
70f4713
Update app.py
josemoracard Dec 13, 2023
a7e83f3
Update README.md
josemoracard Dec 13, 2023
2cd8b8d
Update README.es.md
josemoracard Dec 13, 2023
33663cf
Update README.md
josemoracard Dec 13, 2023
1d0e704
Update README.es.md
josemoracard Dec 13, 2023
2e9fd8a
Update solution.hide.py
josemoracard Dec 13, 2023
1990089
Update solution.hide.py
josemoracard Dec 13, 2023
e5c8075
Update README.md
josemoracard Dec 13, 2023
5a61d9c
Update README.es.md
josemoracard Dec 13, 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
12 changes: 7 additions & 5 deletions exercises/017-total_cost/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

## 📝 Instrucciones:

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*
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*

## Ejemplo de entrada:
## 📎 Ejemplo de entrada:

```py
total_cost(10,15,2)
```

## Ejemplo de salida:
## 📎 Ejemplo de salida:

+ (20, 30)
```py
(20, 30)
```

## 💡 Pistas:

+ 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/

+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/
+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/
12 changes: 7 additions & 5 deletions exercises/017-total_cost/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

## 📝 Instructions:

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.*
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.*

## Example input:
## 📎 Example input:

```py
total_cost(10,15,2)
```

## Example output:
## 📎 Example output:

+ (20, 30)
```py
(20, 30)
```

## 💡 Hints:

+ 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/
+ 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/

+ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/
11 changes: 4 additions & 7 deletions exercises/017-total_cost/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#Complete the function to return the total cost in dollars and cents of N cupcakes.
#Remember you can return multiple parameters => return a, b
def total_cost(d,c,n):
# Complete the function to return the total cost in dollars and cents of (n) cupcakes
def total_cost(d, c, n):
return None




#Invoke the function with three intergers: cost(dollars and cents) & number of cupcakes.
print(total_cost())
# Invoke the function with three integers: total_cost(dollars, cents, number_of_cupcakes)
print(total_cost(15,22,4))
14 changes: 7 additions & 7 deletions exercises/017-total_cost/solution.hide.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#Complete the function to return the total cost in dollars and cents of N cupcakes.
#Remember you can return multiple parameters => return a, b
def total_cost(d,c,n):
return ((((d*100)+c)*n)//100, (((d*100)+c)*n)%100)

# Complete the function to return the total cost in dollars and cents of (n) cupcakes
def total_cost(d, c, n):
total_cents = (d * 100 + c) * n
total_dollars = total_cents // 100
remaining_cents = total_cents % 100
return total_dollars, remaining_cents



#Invoke the function with three intergers: cost(dollars and cents) & number of cupcakes.
# Invoke the function with three integers: total_cost(dollars, cents, number_of_cupcakes)
print(total_cost(15,22,4))
6 changes: 3 additions & 3 deletions exercises/017-total_cost/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def test_function_return_type_parameters(capsys, app):
result = app.total_cost(15, 22, 4)
assert type(result[0]) == type(1) and type(result[1]) == type(1)

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

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

16 changes: 10 additions & 6 deletions exercises/018-day_of_week/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@

## 📝 Instrucciones:

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.
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.

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

```text
0 — Domingo
1 — Lunes
2 — Martes, ...
6 — Sábado.
6 — Sábado
```

## Ejemplo de entrada:
## 📎 Ejemplo de entrada:

```py
day_of_week(1)
```

## Ejemplo de salida:
## 📎 Ejemplo de salida:

+ 4
```py
4
```

## 💡 Pistas:

+ 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/

+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/
+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/
20 changes: 12 additions & 8 deletions exercises/018-day_of_week/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@

## 📝 Instructions:

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.
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.

*Days of week are numbered as:*
*The days of the week are numbered as:*

```text
0 — Sunday
1 — Monday
2 — Tuesday, ...
6 — Saturday.
6 — Saturday
```

## Example input:
## 📎 Example input:

```py
day_of_week(1)
```

## Example output:
## 📎 Example output:

+ 4
```py
4
```

## 💡 Hints:

+ 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/
+ 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/

+ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/
+ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/
8 changes: 3 additions & 5 deletions exercises/018-day_of_week/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#Complete the function to return the number of day of the week for k'th day of year.
# Complete the function to return the number of day of the week for k'th day of year
def day_of_week(k):

return None



#Invoke function day_of_week with an interger between 0 and 6 (number for days of week)
print(day_of_week())
# Invoke function day_of_week with an integer between 1 and 365
print(day_of_week())
10 changes: 4 additions & 6 deletions exercises/018-day_of_week/solution.hide.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#Complete the function to return the number of day of the week for k'th day of year.
# Complete the function to return the number of day of the week for k'th day of year
def day_of_week(k):

return (3+k)%7
return (3 + k) % 7



#Invoke function day_of_week with an interger between 0 and 6 (number for days of week)
print(day_of_week(1))
# Invoke function day_of_week with an integer between 1 and 365
print(day_of_week(125))
4 changes: 2 additions & 2 deletions exercises/018-day_of_week/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def test_function_return(capsys, app):
def test_function_return_type(capsys, app):
assert type(app.day_of_week(1)) == type(1)

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

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

14 changes: 8 additions & 6 deletions exercises/019-digital_clock/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@

## 📝 Instrucciones:

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).*
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).*

## Ejemplo de entrada:
## 📎 Ejemplo de entrada:

```py
digital_clock(150)
```

## Ejemplo de salida:
## 📎 Ejemplo de salida:

+ (2, 30)
```py
(2, 30)
```

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.
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).

## 💡 Pistas:

+ 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/

+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/
+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/
16 changes: 9 additions & 7 deletions exercises/019-digital_clock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@

## 📝 Instructions:

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).*
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).*

## Example input:
## 📎 Example input:

```py
digital_clock(150)
```

## Example output:
## 📎 Example output:

+ (2, 30)
```py
(2, 30)
```

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.
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).

## 💡 Hints:

+ 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/
+ 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/

+ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/
+ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/
4 changes: 2 additions & 2 deletions exercises/019-digital_clock/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Complete the function to return how many hrs and min are displayed on the 24th digital clock.
# Complete the function to return how many hours and minutes are displayed on the 24h digital clock
def digital_clock(n):
return None

#Invoke the function with any interger (seconds after midnight)
# Invoke the function with any integer (minutes after midnight)
print(digital_clock())
4 changes: 2 additions & 2 deletions exercises/019-digital_clock/solution.hide.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Complete the function to return how many hrs and min are displayed on the 24th digital clock.
# Complete the function to return how many hours and minutes are displayed on the 24h digital clock
def digital_clock(n):
return ((n // 60), (n % 60))

#Invoke the function with any interger (seconds after midnight)
# Invoke the function with any integer (minutes after midnight)
print(digital_clock(150))
6 changes: 3 additions & 3 deletions exercises/019-digital_clock/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def test_function_return(capsys, app):
def test_function_return_type(capsys, app):
assert type(app.digital_clock(194)) == type((3, 14))

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

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

10 changes: 6 additions & 4 deletions exercises/020-factorial/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

## 📝 Instrucciones:

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

## Ejemplo de entrada:
## 📎 Ejemplo de entrada:

```py
factorial(8)
```

## Ejemplo de salida:
## 📎 Ejemplo de salida:

+ 40320
```py
40320
```

## 💡 Pista:

Expand Down
10 changes: 6 additions & 4 deletions exercises/020-factorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

## 📝 Instructions:

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

## Example input:
## 📎 Example input:

```py
factorial(8)
```

## Example output:
## 📎 Example output:

+ 40320
```py
40320
```

## 💡 Hint:

Expand Down
Loading