You are on page 1of 3

#County data - copied from text document

PA=​"""Erie County 272061 1


Warren County 39498 2
McKean County 40968 3
Potter County 16622 4
Tioga County 40763 5
Bradford County 60833 6
Susquehanna County 40589 7
Wayne County 51276 8
Pike County 55933 9
Monroe County 169507 10
Lackawanna County 210793 11
Luzerne County 317646 12
Wyoming County 27046 13
Sullivan County 6071 14
Columbia County 65456 15
Montour County 18240 16
Northumberland County 91083 17
Snyder County 40540 18
Union County 44785 19
Lycoming County 113664 20
Clinton County 38684 21
Centre County 162805 22
Clearfield County 79388 23
Cameron County 4492 24
Elk County 30169 25
Jefferson County 43641 26
Clarion County 38779 27
Forest County 7279 28
Venango County 51266 29
Crawford County 85063 30
Mercer County 110683 31
Lawrence County 86184 32
Beaver County 164742 33
Butler County 187888 34
Armstrong County 65263 35
Indiana County 84501 36
Cambria County 131730 37
Blair County 122492 38
Huntingdon County 45168 39
Mifflin County 46222 40
Juniata County 24704 41
Perry County 46139 42
Dauphin County 277097 43
Lebanon County 141314 44
Schuylkill County 142067 45
Carbon County 64227 46
Northampton County 304807 47
Bucks County 628195 48
Lehigh County 368100 49
Berks County 420152 50
Montgomery County 828604 51
Philadelphia County 1584140 52
Delaware County 564751 53
Chester County 522046 54
Lancaster County 543557 55
York County 448273 56
Adams County 102811 57
Cumberland County 251423 58
Franklin County 154835 59
Fulton County 14523 60
Bedford County 48176 61
Somerset County 73952 62
Fayette County 130441 63
Greene County 36506 64
Washington County 207346 65
Westmoreland County 350611 66
Allegheny County 1218450 67"""

#Organize the data into lists

county_names = []
county_pop = []
county_order = []

for​ i ​in​ range(​0,268,4​):


county_names.​append​(PA.split()[i])

for​ i ​in​ range(​2,268,4​):


county_pop.​append​(int(PA.split()[i]))

for​ i ​in​ range(​3,268,4​):


county_order.​append​(PA.split()[i])

#DEFINING VARIABLES AND COMPLETING THE ACTUAL REDISTRICTING PROCESS


#d = population left from previous county
#x = population of current county (county being operated on)
#k = population of the district being formed
#c = number of counties
#i = index of counties (number of counties counted)

i = ​0
d = ​ 0
k = ​ 11503
7
c = ​67
dname = []
dpop = []

for​ a ​in​ range(​c​):


x = county_pop[a]
y = ​int​(x)+​int​(d)
​if​ y < k:
d=y
dname.​append​(county_names[a])
dpop.​append​(county_pop[a])
​else​:
​if​ k <= y ​and​ y < 2*k:
i = i + 1
dname.​append​(county_names[a])
dname.​append​(​"49908939-"​ + ​str​(i))
dname.​append​(county_names[a])
dpop.​append​(k-y+​int​(x))
dpop.​append​(​"DISTRICT"​ + ​str​(i))
y = y - k
d = y
dpop.​append​(d)
​else​:
i = i + 1
dname.​append​(county_names[a])
dname.​append​(​"49908939-"​ + ​str​(i))
dpop.​append​(k-y+​int​(x))
dpop.​append​(​"DISTRICT"​ + ​str​(i))
y = y - k
d = y
​while​ y > k:
i = i + 1
dname.​append​(county_names[a])
dname.​append​(​"49908939-"​ + ​str​(i))
dname.​append​(county_names[a])
dpop.​append​(k)
dpop.​append​(​"DISTRICT"​ + ​str​(i))
dpop.​append​(y-k)
y = y - k
d = y

print​(​dname​)
print​(​dpop​)

You might also like