Question: Given the dictionary states where the key is the state and the value is the population. Sort states on population and print the three states
Given the dictionary states where the key is the state and the value is the population. Sort states on population and print the three states with the highest population and the three states with the lowest population.
Given:
states = {"California":39536653,"Texas":28304596,"Florida":20984400,"New York":19849399,"Pennsylvania":12805537,"Illinois":12802023,"Ohio":11658609,"Georgia":10429379,"North Carolina":10273419,"Michigan":9962311,"New
Jersey":9005644,"Virginia":8470020,"Washington":7405743,"Arizona":7016270,"Massachusetts":6859819,"Tennessee":6715984,"Indiana":6666818,"Missouri":6113532,"Maryland":6052177,"Wisconsin":5795483, "Colorado":5607154,"Minnesota":5576606,"South Carolina":5024369,"Alabama":4874747,"Louisiana":4684333, "Kentucky":4454189,"Oregon":4142776,"Oklahoma":3930864,"Connecticut":3588184,"Puerto Rico":3337177, "Iowa":3145711,"Utah":3101833,"Arkansas":3004279,"Nevada":2998039,"Mississippi":2984100,"Kansas":2913123, "New Mexico":2088070,"Nebraska":1920076,"West Virginia":1815857,"Idaho":1716943,"Hawaii":1427538, "New Hampshire":1342795,"Maine":1335907,"Rhode Island":1059639,"Montana":1050493,"Delaware":961939, "South Dakota":869666,"North Dakota":755393,"Alaska":739795,"District of Columbia":693972,"Vermont":623657 "Wyoming":579315}
Expected Output:
The three states with the lowest population are ['Wyoming', 'Vermont', 'District of Columbia'] The three states with the largest population are ['California', 'Texas', 'Florida']
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
