Ask Question
24 June, 16:49

Given a variable, polygon_sides, that is associated with a dictionary that maps names of polygons to number of sides, create a new dictionary that maps number of sides to polygon names, and associate it with a variable n_polygons.

+2
Answers (1)
  1. 24 June, 18:21
    0
    polygon_sides = {"Triangle" : 3,"Square" : 5}

    n_polygons = {}

    for key in polygon_sides:

    n_polygons[polygon_sides[key]] = key

    print ("Polygon sides: ", polygon_sides)

    print ("Names of polygons: ", n_polygons)

    Explanation:

    Initialize the polygon_sides dictionary. Loop through polygon_sides dictionary and assign the associated names to n_polygons variable. Display the polygon sides and the names of polygons.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Given a variable, polygon_sides, that is associated with a dictionary that maps names of polygons to number of sides, create a new ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers