-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_programming.py
39 lines (35 loc) · 1.23 KB
/
class_programming.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
class County:
def __init__(self,init_name,init_population,init_turnout):
self.name = init_name
self.population = init_population
self.turnout = init_turnout
def highest_turnout(data):
d = data.copy()
highper = []
for county in data:
x = county.turnout
y = county.population
z = x/y
highper.append(z)
out = (max(highper))
i = highper.index(out)
n = d[i]
a = n.name
b = n.population
c = round(out,1)
tup = (a,b,c)
return tup
# your program will be evaluated using these objects
# it is okay to change/remove these lines but your program
# will be evaluated using these as inputs
allegheny = County("allegheny", 1000490, 645469)
philadelphia = County("philadelphia", 1134081, 539069)
montgomery = County("montgomery", 568952, 399591)
lancaster = County("lancaster", 345367, 230278)
delaware = County("delaware", 414031, 284538)
chester = County("chester", 319919, 230823)
bucks = County("bucks", 444149, 319816)
data = [allegheny, philadelphia, montgomery, lancaster, delaware, chester, bucks]
result = highest_turnout(data) # do not change this line!
print(result) # prints the output of the function
# do not remove this line!