Se ofrecen a continuación unas posibles soluciones de los ejercicios de SVG Ficheros (1 B).
import webbrowser
def main():
ruta = "svg-ficheros-1-b-1-1.html"
with open(ruta, mode="w", encoding="utf-8") as fichero:
print("<!DOCTYPE html>", file=fichero)
print("<html lang=\"es\">", file=fichero)
print("<head>", file=fichero)
print(" <meta charset=\"utf-8\" />", file=fichero)
print(" <title>Ficheros (1 B) 1-1. SVG. Ejercicios. Python</title>", file=fichero)
print(" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />",
file=fichero)
print("</head>", file=fichero)
print("", file=fichero)
print("<body>", file=fichero)
print(" <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"", file=fichero)
print(" width=\"320\" height=\"320\" viewBox=\"-10 -10 320 320\"", file=fichero)
print(" style=\"border: black 1px solid\">", file=fichero)
print(" <line x1=\"100\" y1=\"0\" x2=\"200\" y2=\"300\" stroke=\"black\" stroke-width=\"2\" />",
file=fichero)
print(" <circle cx=\"100\" cy=\"0\" r=\"5\" stroke=\"black\" stroke-width=\"2\" fill=\"white\"/>",
file=fichero)
print(" <circle cx=\"200\" cy=\"300\" r=\"5\" stroke=\"black\" stroke-width=\"2\" fill=\"white\"/>",
file=fichero)
print(" <line x1=\"0\" y1=\"200\" x2=\"300\" y2=\"100\" stroke=\"black\" stroke-width=\"2\" />",
file=fichero)
print(" <circle cx=\"0\" cy=\"200\" r=\"5\" stroke=\"black\" stroke-width=\"2\" fill=\"white\"/>",
file=fichero)
print(" <circle cx=\"300\" cy=\"100\" r=\"5\" stroke=\"black\" stroke-width=\"2\" fill=\"white\"/>",
file=fichero)
print(" <circle cx=\"150\" cy=\"150\" r=\"5\" stroke=\"black\" stroke-width=\"2\" fill=\"white\"/>",
file=fichero)
print(" </svg>", file=fichero)
print("</body>", file=fichero)
print("</html>", file=fichero)
webbrowser.open(ruta)
if __name__ == "__main__":
main()
import webbrowser
def main():
ruta = "svg-ficheros-1-b-1-2.html"
with open(ruta, mode="w", encoding="utf-8") as fichero:
print("<!DOCTYPE html>", file=fichero)
print("<html lang=\"es\">", file=fichero)
print("<head>", file=fichero)
print(" <meta charset=\"utf-8\" />", file=fichero)
print(" <title>Ficheros (1 B) 1-2. SVG. Ejercicios. Python</title>", file=fichero)
print(" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />",
file=fichero)
print("</head>", file=fichero)
print("", file=fichero)
print("<body>", file=fichero)
print(" <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"", file=fichero)
print(" width=\"320\" height=\"320\" viewBox=\"-10 -10 320 320\"", file=fichero)
print(" style=\"border: black 1px solid\">", file=fichero)
print(" <polygon points=\"225,0 300,225 75,300 0,75\" fill=\"none\" stroke=\"red\" stroke-width=\"5\" />",
file=fichero)
print(" <circle cx=\"150\" cy=\"150\" r=\"118\" stroke=\"red\" stroke-width=\"5\" fill=\"white\"/>",
file=fichero)
print(" </svg>", file=fichero)
print("</body>", file=fichero)
print("</html>", file=fichero)
webbrowser.open(ruta)
if __name__ == "__main__":
main()
import webbrowser
def main():
ruta = "svg-ficheros-1-b-1-3.html"
with open(ruta, mode="w", encoding="utf-8") as fichero:
print("<!DOCTYPE html>", file=fichero)
print("<html lang=\"es\">", file=fichero)
print("<head>", file=fichero)
print(" <meta charset=\"utf-8\" />", file=fichero)
print(" <title>Ficheros (1 B) 1-3. SVG. Ejercicios. Python</title>", file=fichero)
print(" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />",
file=fichero)
print("</head>", file=fichero)
print("", file=fichero)
print("<body>", file=fichero)
print(" <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"", file=fichero)
print(" width=\"320\" height=\"320\" viewBox=\"-160 -160 320 320\"", file=fichero)
print(" style=\"border: black 1px solid\">", file=fichero)
print(" <circle cx=\"0\" cy=\"0\" r=\"150\" stroke=\"black\" stroke-width=\"3\" fill=\"none\"/>",
file=fichero)
print(" <circle cx=\"50\" cy=\"-50\" r=\"25\" stroke=\"black\" stroke-width=\"3\" fill=\"none\"/>",
file=fichero)
print(" <circle cx=\"-50\" cy=\"-50\" r=\"25\" stroke=\"black\" stroke-width=\"3\" fill=\"none\"/>",
file=fichero)
print(" <polyline points=\"0,0 25,25 0,50 25,75 0,100\" stroke=\"black\" stroke-width=\"3\" fill=\"none\"/>",
file=fichero)
print(" </svg>", file=fichero)
print("</body>", file=fichero)
print("</html>", file=fichero)
webbrowser.open(ruta)
if __name__ == "__main__":
main()
import webbrowser
def main():
ruta = "svg-ficheros-1-b-2-1.html"
with open(ruta, mode="w", encoding="utf-8") as fichero:
print("<!DOCTYPE html>", file=fichero)
print("<html lang=\"es\">", file=fichero)
print("<head>", file=fichero)
print(" <meta charset=\"utf-8\" />", file=fichero)
print(" <title>Ficheros (1 B) 2-1. SVG. Ejercicios. Python</title>", file=fichero)
print(" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />", file=fichero)
print("</head>", file=fichero)
print("", file=fichero)
print("<body>", file=fichero)
print(" <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"", file=fichero)
print(" width=\"320\" height=\"320\" viewBox=\"-10 -10 320 320\"", file=fichero)
print(" style=\"border: black 1px solid\">", file=fichero)
print(" <rect x=\"0\" y=\"0\" width=\"100\" height=\"100\" fill=\"green\" />", file=fichero)
print(" <rect x=\"200\" y=\"0\" width=\"100\" height=\"100\" fill=\"blue\" />", file=fichero)
print(" <rect x=\"200\" y=\"200\" width=\"100\" height=\"100\" fill=\"red\" />", file=fichero)
print(" <rect x=\"0\" y=\"200\" width=\"100\" height=\"100\" fill=\"yellow\" />", file=fichero)
print(" <rect x=\"100\" y=\"100\" width=\"100\" height=\"100\" fill=\"black\" />", file=fichero)
print(" <circle cx=\"50\" cy=\"50\" r=\"10\" fill=\"white\" />", file=fichero)
print(" <circle cx=\"250\" cy=\"250\" r=\"10\" fill=\"white\" />", file=fichero)
print(" </svg>", file=fichero)
print("</body>", file=fichero)
print("</html>", file=fichero)
webbrowser.open(ruta)
if __name__ == "__main__":
main()
import webbrowser
def main():
ruta = "svg-ficheros-1-b-2-2.html"
with open(ruta, mode="w", encoding="utf-8") as fichero:
print("<!DOCTYPE html>", file=fichero)
print("<html lang=\"es\">", file=fichero)
print("<head>", file=fichero)
print(" <meta charset=\"utf-8\" />", file=fichero)
print(" <title>Ficheros (1 B) 2-2. SVG. Ejercicios. Python</title>", file=fichero)
print(" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />", file=fichero)
print("</head>", file=fichero)
print("", file=fichero)
print("<body>", file=fichero)
print(" <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"", file=fichero)
print(" width=\"320\" height=\"320\" viewBox=\"-10 -10 320 320\"", file=fichero)
print(" style=\"border: black 1px solid\">", file=fichero)
print(" <polygon points=\"0,300 100,300 50,200\" fill=\"red\" />", file=fichero)
print(" <polygon points=\"100,300 200,300 150,200\" fill=\"red\" />", file=fichero)
print(" <polygon points=\"200,300 300,300 250,200\" fill=\"red\" />", file=fichero)
print(" <polygon points=\"50,200 150,200 100,100\" fill=\"green\" />", file=fichero)
print(" <polygon points=\"150,200 250,200 200,100\" fill=\"green\" />", file=fichero)
print(" <polygon points=\"100,100 200,100 150,0\" fill=\"blue\" />", file=fichero)
print(" </svg>", file=fichero)
print("</body>", file=fichero)
print("</html>", file=fichero)
webbrowser.open(ruta)
if __name__ == "__main__":
main()
import webbrowser
def main():
ruta = "svg-ficheros-1-b-2-3.html"
with open(ruta, mode="w", encoding="utf-8") as fichero:
print("<!DOCTYPE html>", file=fichero)
print("<html lang=\"es\">", file=fichero)
print("<head>", file=fichero)
print(" <meta charset=\"utf-8\" />", file=fichero)
print(" <title>Ficheros (1 B) 2-3. SVG. Ejercicios. Python</title>", file=fichero)
print(" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />", file=fichero)
print("</head>", file=fichero)
print("", file=fichero)
print("<body>", file=fichero)
print(" <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"", file=fichero)
print(" width=\"320\" height=\"320\" viewBox=\"-160 -160 320 320\"", file=fichero)
print(" style=\"border: black 1px solid\">", file=fichero)
print(" <circle cx=\"75\" cy=\"0\" r=\"75\" fill=\"red\" />", file=fichero)
print(" <circle cx=\"-75\" cy=\"0\" r=\"75\" fill=\"red\" />", file=fichero)
print(" <rect x=\"-75\" y=\"-75\" width=\"150\" height=\"150\" fill=\"red\" />", file=fichero)
print(" </svg>", file=fichero)
print("</body>", file=fichero)
print("</html>", file=fichero)
webbrowser.open(ruta)
if __name__ == "__main__":
main()
import webbrowser
def main():
ruta = "svg-ficheros-1-b-3-1.html"
with open(ruta, mode="w", encoding="utf-8") as fichero:
print("<!DOCTYPE html>", file=fichero)
print("<html lang=\"es\">", file=fichero)
print("<head>", file=fichero)
print(" <meta charset=\"utf-8\" />", file=fichero)
print(" <title>Ficheros (1 B) 3-1. SVG. Ejercicios. Python</title>", file=fichero)
print(" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />", file=fichero)
print("</head>", file=fichero)
print("", file=fichero)
print("<body>", file=fichero)
print(" <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"", file=fichero)
print(" width=\"320\" height=\"320\" viewBox=\"-160 -160 320 320\"", file=fichero)
print(" style=\"border: black 1px solid\">", file=fichero)
print(" <rect x=\"-100\" y=\"-100\" width=\"100\" height=\"100\" fill=\"red\" />", file=fichero)
print(" <circle cx=\"-100\" cy=\"-50\" r=\"50\" fill=\"red\" />", file=fichero)
print(" <circle cx=\"-50\" cy=\"-100\" r=\"50\" fill=\"red\" />", file=fichero)
print(" <rect x=\"0\" y=\"0\" width=\"100\" height=\"100\" fill=\"pink\" />", file=fichero)
print(" <circle cx=\"100\" cy=\"50\" r=\"50\" fill=\"pink\" />", file=fichero)
print(" <circle cx=\"50\" cy=\"100\" r=\"50\" fill=\"pink\" />", file=fichero)
print(" </svg>", file=fichero)
print("</body>", file=fichero)
print("</html>", file=fichero)
webbrowser.open(ruta)
if __name__ == "__main__":
main()
import webbrowser
def main():
ruta = "svg-ficheros-1-b-3-2.html"
with open(ruta, mode="w", encoding="utf-8") as fichero:
print("<!DOCTYPE html>", file=fichero)
print("<html lang=\"es\">", file=fichero)
print("<head>", file=fichero)
print(" <meta charset=\"utf-8\" />", file=fichero)
print(" <title>Ficheros (1 B) 3-2. SVG. Ejercicios. Python</title>", file=fichero)
print(" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />", file=fichero)
print("</head>", file=fichero)
print("", file=fichero)
print("<body>", file=fichero)
print(" <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"", file=fichero)
print(" width=\"320\" height=\"320\" viewBox=\"-10 -10 320 320\"", file=fichero)
print(" style=\"border: black 1px solid\">", file=fichero)
print(" <rect x=\"0\" y=\"0\" width=\"300\" height=\"300\" fill=\"black\" />", file=fichero)
print(" <rect x=\"50\" y=\"150\" width=\"200\" height=\"100\" fill=\"orange\" />", file=fichero)
print(" <circle cx=\"150\" cy=\"150\" r=\"100\" fill=\"orange\" />", file=fichero)
print(" <circle cx=\"70\" cy=\"250\" r=\"20\" fill=\"orange\" />", file=fichero)
print(" <circle cx=\"110\" cy=\"250\" r=\"20\" fill=\"black\" />", file=fichero)
print(" <circle cx=\"150\" cy=\"250\" r=\"20\" fill=\"orange\" />", file=fichero)
print(" <circle cx=\"190\" cy=\"250\" r=\"20\" fill=\"black\" />", file=fichero)
print(" <circle cx=\"230\" cy=\"250\" r=\"20\" fill=\"orange\" />", file=fichero)
print(" <circle cx=\"210\" cy=\"130\" r=\"25\" fill=\"white\" />", file=fichero)
print(" <circle cx=\"220\" cy=\"135\" r=\"15\" fill=\"blue\" />", file=fichero)
print(" <circle cx=\"150\" cy=\"130\" r=\"25\" fill=\"white\" />", file=fichero)
print(" <circle cx=\"160\" cy=\"135\" r=\"15\" fill=\"blue\" />", file=fichero)
print(" </svg>", file=fichero)
print("</body>", file=fichero)
print("</html>", file=fichero)
webbrowser.open(ruta)
if __name__ == "__main__":
main()
import webbrowser
def main():
ruta = "svg-ficheros-1-b-3-3.html"
with open(ruta, mode="w", encoding="utf-8") as fichero:
print("<!DOCTYPE html>", file=fichero)
print("<html lang=\"es\">", file=fichero)
print("<head>", file=fichero)
print(" <meta charset=\"utf-8\" />", file=fichero)
print(" <title>Ficheros (1 B) 3-3. SVG. Ejercicios. Python</title>", file=fichero)
print(" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />", file=fichero)
print("</head>", file=fichero)
print("", file=fichero)
print("<body>", file=fichero)
print(" <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"", file=fichero)
print(" width=\"320\" height=\"320\" viewBox=\"-10 -10 320 320\"", file=fichero)
print(" style=\"border: black 1px solid\">", file=fichero)
print(" <circle cx=\"150\" cy=\"150\" r=\"150\" fill=\"black\" />", file=fichero)
print(" <rect x=\"0\" y=\"0\" width=\"150\" height=\"300\" fill=\"white\" />", file=fichero)
print(" <circle cx=\"150\" cy=\"150\" r=\"151\" fill=\"none\" stroke=\"black\" stroke-width=\"2\" />", file=fichero)
print(" <circle cx=\"150\" cy=\"225\" r=\"75\" fill=\"black\" />", file=fichero)
print(" <circle cx=\"150\" cy=\"75\" r=\"75\" fill=\"white\" />", file=fichero)
print(" <circle cx=\"150\" cy=\"75\" r=\"25\" fill=\"black\" />", file=fichero)
print(" <circle cx=\"150\" cy=\"225\" r=\"25\" fill=\"white\" />", file=fichero)
print(" </svg>", file=fichero)
print("</body>", file=fichero)
print("</html>", file=fichero)
webbrowser.open(ruta)
if __name__ == "__main__":
main()