-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask0.py
52 lines (41 loc) · 1.32 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
"""
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 first_record_texts():
first_text = texts[0]
# assuming that all records are correct (have 3 entries)
incoming_no = first_text[0]
answering_no = first_text[1]
timestamp = first_text[2]
print("First record of texts, " + incoming_no + " texts " + answering_no + " at time " + timestamp)
def last_record_calls():
last_call = calls[-1]
# assuming that all records are correct (have 4 entries)
incoming_no = last_call[0]
answering_no = last_call[1]
timestamp = last_call[2]
duration = last_call[3]
print(
"Last record of calls, " + incoming_no +
" calls " + answering_no +
" at time " + timestamp +
", lasting " + duration +
" seconds"
)
first_record_texts()
last_record_calls()