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.

Respuesta :

Answer:

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.