Rectángulo de rectángulos svg de la base de datos

Estoy leyendo rectángulos svg de una base de datos usando python, no sé si esta es la forma correcta, ya que parece que estoy codificando, esto porque quiero que cada rectángulo cambie los colores en mi hoja de estilo CSS. ¿Hay una mejor manera de llamar a estos rectángulos en lugar de usar ifs y elifs porque si tengo 100 rectángulos, cuál es la mejor manera de hacerlo? También agregué mi hoja de estilo

for row in c: 

 box_x = ((row[3]-row[1])/2 + row[1] - 0.25)
 box_y = ((row[4]-row[2])/2 + row[2] - 0.25)
 move1 = box_y * 2
 try1 =  row[1] * 2  

 if row[0] == 1:
    print('<rect id= rectangle1 class= "rectangles" onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 elif row[0] == 2:
    print('<rect  id="rectangle2" class= "rectangles"   onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 elif row[0] == 3:
    print('<rect  id="rectangle3" class= "rectangles"  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 elif row[0] == 4:
    print('<rect id="rectangle4" class= "rectangles" onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 elif row[0] == 5:
    print('<rect id="rectangle5" class= "rectangles"  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 elif row[0] == 6:
    print('<rect id="rectangle6" class= "rectangles"  onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 elif row[0] == 7:
    print('<rect id="rectangle7" class= "rectangles"  onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')
 else:
    print('<rect id="rectangle8" class= "rectangles"  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onmousemove="myFunction3()" x=',row[1],' y=',row[2],' width=',row[3]-row[1],' height=',row[4]-row[2],'><title>Owned by',row[6],'</title></rect>')

hoja de estilo css

.rectangles{
        fill:       #ff3333;
        stroke:     #000000;
        stroke-width:   0.1; 

}
#rectangle1:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #A52A2A;
}  
#rectangle2:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #A52A2A;
}
#rectangle3:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #006400;
}
#rectangle4:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #000000;
}
#rectangle5:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #006400;
}
#rectangle6:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #000000;
}
#rectangle7:hover{
        stroke:     #FF7F00
        stroke-width:   0.1;
        fill:       #FFFFFF;
}
#rectangle8:hover{
        stroke:     #FF7F00;
        stroke-width:   0.1;
        fill:       #FFFFFF;
}

Respuestas a la pregunta(1)

Su respuesta a la pregunta