-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprac_one.py
48 lines (39 loc) · 1012 Bytes
/
prac_one.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
# Exercise one
# Default display code
class Dataset:
def __init__(self):
self.type = "csv"
# Solution code
class Dataset:
def __init__(self, data):
self.data = data
f = open("nfl.csv", 'r')
csvreader = csv.reader(f)
nfl_data = list(csvreader)
nfl_dataset = Dataset(nfl_data)
dataset_data = nfl_dataset.data
# Exercise two
# Default display code
class Dataset:
def __init__(self, data):
self.data = data
# Your method goes here
# Solution code
class Dataset:
def __init__(self, data):
self.data = data
def print_data(self, num_rows):
print(self.data[:num_rows])
nfl_dataset = Dataset(nfl_data)
nfl_dataset.print_data(5)
# Exercise three
# Default display code
class Dataset:
def __init__(self, data):
self.data = data
class Dataset:
def extract_header(self):
self.header = self.data[0]
self.data = self.data[1:]
nfl_dataset = Dataset(nfl_data)
nfl_header = nfl_dataset.extract_header()