Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Zombies are taking over the world. The Zombie Resistance Army has limited resour

ID: 3793204 • Letter: Z

Question

Zombies are taking over the world. The Zombie Resistance Army has limited resources to fight the zombies, so they must deploy their resources where there are the most zombies. They keep records of the estimated number of zombies present in cities across the globe. Suppose that the Python variable zombie_counts refers to a dictionary that represents a mapping from cites to the current estimated zombie population, that is, a dictionary where the keys are city names (strings) and their associated values are the estimated zombie population in that city (integers). Write Python code that prints out, one per line, the city names from zombie_counts that have an estimated zombie population of more than 10000.

Explanation / Answer

PYTHON CODE

zombie_count={'london':9000,
          'newyork':11000,
          'mumbai':13000,
          'hongkong':18000,
          'sydney':6000}
print('Following cities having zombie count of more than 10000')
for k,v in zombie_count.items():
    if zombie_count[k] > 10000:
        print(k,v)

SAMPLE OUTPUT

Following cities having zombie count of more than 10000
hongkong 18000
mumbai 13000
newyork 11000