-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTask0.py
54 lines (41 loc) · 1.61 KB
/
Task0.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 0:
What is the first record of texts and what is the last record of calls?
Print messages:
"First record of texts, <incoming number> texts <answering number> at time <time>"
"Last record of calls, <incoming number> calls <answering number> at time <time>, lasting <during> seconds"
"""
def main():
"""
Gets the 1st texts and last calls records. Prints 2 messages:
"First record of texts, <incoming number> texts <answering number> at time <time>"
"Last record of calls, <incoming number> calls <answering number> at time <time>, lasting <during> seconds"
"""
print("First record of texts, {} texts {} at time {}".format(*texts[0]))
print("Last record of calls, {} calls {} at time {}, lasting {} seconds".format(*calls[-1]))
def run_tests():
"""
Runs the test suite. Prints "All tests passed!" when all of the tests pass; else, assertion error is displayed.
"""
import io
from contextlib import redirect_stdout
actual = None
with io.StringIO() as obuffer, redirect_stdout(obuffer):
main()
actual = obuffer.getvalue()
assert("First record of texts, 97424 22395 texts 90365 06212 at time 01-09-2016 06:03:22" in actual)
assert ("Last record of calls, 98447 62998 calls (080)46304537 at time 30-09-2016 23:57:15" in actual)
print('All tests passed!')
#run_tests()
main()