File tree

10 files changed

+89
-31
lines changed

10 files changed

+89
-31
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1-
# `007` hours and minutes
1+
# `007` Hours and minutes
22

3-
## 📝 Instrucciones:
3+
En este ejercicio vamos a suponer que es medianoche, queremos que con la función `hours_minutes` que hemos previsto para tí, nos digas cuánto tiempo ha pasado desde entonces con los segundos que se introduzcan como parámetro.
44

5-
1. Dado el número entero `N` - el número de segundos que pasan desde la medianoche ¿Cuántas horas y minutos completos han pasado desde la medianoche? *La función debe imprimir dos números: el número de horas (entre 0 y 23) y el número de minutos (entre 0 y 1339)*.
5+
## 📝 Instrucciones:
66

7-
## Ejemplo:
7+
1. Completa la función para que retorne el resultado esperado.
88

9-
* Si N = 3900 --> han pasado 3900 segundos desde la medianoche ,es decir, ahora es la 1:05 am.
10-
11-
+ El programa debe imprimir 1 65 --> 1 hora completa ha pasado desde la medianoche, 65 minutos completos han pasado desde la medianoche.
9+
2. Realiza dos calculos con los segundos que se pasan por parámetro en la función para que uno calcule la hora según los segundos que han pasado y el otro para saber los minutos `(hora , minutos)`
1210

13-
## Ejemplo de entrada:
11+
## Ejemplo 1:
1412

1513
```py
16-
hours_minutes(3900)
14+
output = hours_minutes(3900)
15+
print(output) # (1, 5)
1716
```
1817

19-
## Ejemplo de salida:
18+
## Ejemplo 2:
2019

21-
+ (1, 65)
20+
```py
21+
output = hours_minutes(60)
22+
print(output) # (0, 1)
23+
```
2224

2325
## 💡 Pistas:
2426

25-
+ Si no sabes por donde partir este ejercicio por favor, revisa la teoría en esta lección: ttps://snakify.org/lessons/print_input_numbers/
27+
+ Recuerda cuantos segundos hay en una hora (3600) y cuantos segundos en un minuto (60).
28+
29+
+ Si no sabes cómo empezar la solución a esta asignación, por favor, revisa la teoría en esta lección: https://snakify.org/lessons/print_input_numbers/
2630

2731
+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/print_input_numbers/steps/1/
32+
33+
[comment]: <Solution: (secs//3600, secs//60)>
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
1-
# `007` hours and minutes
1+
# `007` Hours and Minutes
22

3-
## 📝 Instructions:
4-
5-
1. Given the integer `N` - the number of seconds that is passed since midnight. - How many full hours and full minutes are passed since midnight? *The program should print two numbers: the number of hours (between 0 and 23) and the number of minutes (between 0 and 1339)*.
3+
In this exercise we are going to suppose that it is midnight, we want that with the function `hours_minutes` that we have provided to you, you were able to tell us how much time has passed since then with the seconds that are introduced as parameter.
64

7-
## Example:
5+
## 📝 Instructions:
86

9-
+ If N = 3900 --> then 3900 seconds have passed since midnight - i.e. now it's 1:05am.
7+
1. Complete the function to return the expected result.
108

11-
+ So the program should print 1 65 --> 1 full hour is passed since midnight, 65 full minutes passed since midnight.
9+
2. Perform two calculations with the seconds that are passed by parameter in the function so that one calculates the time according to the seconds that have passed and the other to know the minutes `(hour , minutes)`.
1210

13-
## Example input:
11+
## Example 1:
1412

1513
```py
16-
hours_minutes(3900)
14+
output = hours_minutes(3900)
15+
print(output) # (1, 5)
1716
```
1817

19-
## Example output:
18+
## Example 2:
2019

21-
+ (1, 65)
20+
```py
21+
output = hours_minutes(60)
22+
print(output) # (0, 1)
23+
```
2224

2325
## 💡 Hints:
2426

27+
+ Remember how many seconds there are in an hour (3600) and how many seconds in a minute (60).
28+
2529
+ If you don't know how to start solving this assignment, please, review a theory for this lesson: https://snakify.org/lessons/print_input_numbers/
2630

2731
+ You may also try step-by-step theory chunks: https://snakify.org/lessons/print_input_numbers/steps/1/
32+
33+
34+
[comment]: <Solution: (secs//3600, secs//60)>
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@ def hours_minutes(secs):
33

44
return None
55

6-
7-
8-
96
#Invoke the funtion and pass any interger as its argument.
107
print(hours_minutes(3900))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#Complete the function to calculate how many hours and minutes are passed since midnight.
2+
def hours_minutes(secs):
3+
minutes = secs // 60
4+
hours = minutes // 60
5+
minutes = minutes % 60
6+
return (hours, minutes)
7+
8+
#Invoke the funtion and pass any interger as its argument.
9+
print(hours_minutes(3900))
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,26 @@
33
@pytest.mark.it('The function hours_minutes must exist')
44
def test_for_functon_existence(capsys, app):
55
assert callable(app.hours_minutes)
6+
7+
@pytest.mark.it('The function hours_minutes must return the correct output for 60 secs')
8+
def test_for_file_output(capsys, app):
9+
assert app.hours_minutes(60) == (0, 1)
610

7-
@pytest.mark.it('The function hours_minutes must return the correct output')
11+
@pytest.mark.it('The function hours_minutes must return the correct output for 3900 secs')
812
def test_for_file_output(capsys, app):
9-
assert app.hours_minutes(4004) == (4004//3600, 4004//60)
13+
assert app.hours_minutes(3900) == (1, 5)
14+
15+
16+
@pytest.mark.it('The function hours_minutes must return the correct output for 4500 secs')
17+
def test_for_file_output(capsys, app):
18+
assert app.hours_minutes(4500) == (1, 15)
19+
20+
21+
@pytest.mark.it('The function hours_minutes must return the correct output for 7320 secs')
22+
def test_for_file_output(capsys, app):
23+
assert app.hours_minutes(7320) == (2, 2)
24+
25+
1026

1127

1228

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
s = input()
2+
words = [word for word in s.split(" ")]
3+
print (" ".join(sorted(list(set(words)))))
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
s = raw_input()
1+
s = input()
22
words = [word for word in s.split(" ")]
3-
print " ".join(sorted(list(set(words))))
3+
print (" ".join(sorted(list(set(words)))))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest, io, sys, json, mock, re, os
2+
3+
@pytest.mark.it('Your solution should work as expected')
4+
def test_expected_output(capsys, app):
5+
fake_input=['Hola como Hola']
6+
with mock.('builtins.input', lambda x: fake_input.pop()):
7+
app()
8+
captured = capsys.readouterr()
9+
assert captured.out == " como \n"
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
break
88
l.append(tuple(s.split(",")))
99

10-
print sorted(l, key=itemgetter(0,1,2))
10+
print (sorted(l, key=itemgetter(0,1,2)))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest, io, sys, json, mock, re, os
2+
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
3+
4+
@pytest.mark.it('The solution should return the expected output')
5+
def test_convert_inputs(capsys, app):
6+
7+
fake_input = ["Tom,19,80 John,20,90 Jony,17,91 Jony,17,93 Json,21,85"] #fake input
8+
with mock.('builtins.input', lambda x: fake_input.pop()):
9+
app()
10+
captured = capsys.readouterr()
11+
assert captured.out == "[('John', '20', '90'), ('Jony', '17', '91'), ('Jony', '17', '93'), ('Json', '21', '85'), ('Tom', '19', '80')]\n"

0 commit comments

Comments
 (0)