Ask Question

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.

+1
Answers (1)
  1. 9 September, 03:37
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers