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

Commit 6c40b2f

Browse files
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

File tree

28 files changed

+228
-151
lines changed

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /