Question 54 States Write a program that displays the nameof
Question 54 States Write a program that displays the nameof the states in the list NE in decending order by population.
NE = [(\"Maine\" , 30840, 1.329) , (\"Vermont\" , 9217, .626), (\"Massachusetts\" , 7800, 6.646), (\"Connecticut\" , 4842, 3.59), (\"Rhode Island\" , 1044, 1.5)]
Use the following list of tuples, where each tuple contains the name, land area in square miles, and population in millions of a New England state. NE = [(\"Maine\", 30840, 1.329), (\"Vermont\", 9217, .626), (\"New Hampshire\", 8953, 1.321), (\"Massachusetts\", 7800, 6.646), (\"Connecticut\", 4842, 3.59), (\"Rhode Island\", 1044, 1.05)] New England Stated Write a program that displays the names of the states in the list NE in descending order by population. See Fig.4.16.Solution
def stateByTop(n): states = NE() for i in range(0,len(states)): madeSwap = False for j in range (0,len(states)-(i+1)): if states[j][2] < states[j+1][2]: temp = states[j+1] states[j+1] = states[j] states[j] = temp madeSwap = True if not madeSwap: return states return states[n]
