Ask Question
29 April, 12:24

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.

+3
Answers (1)
  1. 29 April, 15:17
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers