Gráficos: el módulo turtle - Soluciones (1)

Se ofrecen a continuación unas posibles soluciones de los ejercicios (1) del módulo turtle. Los ejercicios están separados en dos bloques:

A. Ventana de tortuga

turtle (1) - A-1

Turtle (1) A-1 1
from turtle import *

setup(640, 480, -1, 0)

exitonclick()

Los valores a escribir dependen del tamaño de la pantalla.

Turtle (1) A-1 2
from turtle import *

setup(640, 480, 300, 360)

exitonclick()

turtle (1) - A-2

Turtle (1) A-2 1
from turtle import *

setup(200, 200, 0, 0)
screensize(100, 100)

exitonclick()
Turtle (1) A-2 2
from turtle import *

setup(200, 200, 0, 0)
screensize(400, 400)

exitonclick()
Turtle (1) A-2 3
from turtle import *

setup(200, 200, 0, 0)
screensize(400, 100)

exitonclick()
Turtle (1) A-2 4
from turtle import *

setup(200, 200, 0, 0)
screensize(100, 800)

exitonclick()
Turtle (1) A-2 5
from turtle import *

setup(400, 200, 0, 0)
screensize(800, 300)

exitonclick()
Turtle (1) A-2 6
from turtle import *

setup(400, 200, 0, 0)
screensize(600, 300)

exitonclick()

B. Puntos y líneas

turtle (1) - B-1

Turtle (1) B-1 1
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
colormode(255)
hideturtle()

penup()
dot(5, 0, 0, 0)
goto(100, 0)
dot(5, 0, 0, 255)
goto(100, 100)
dot(5, 255, 0, 0)
goto(0, 100)
dot(5, 0, 255, 0)

exitonclick()
Turtle (1) B-1 2
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
colormode(255)
hideturtle()

penup()
goto(100, 100)
dot(10, 0, 0, 0)
goto(100, -100)
dot(10, 255, 0, 0)
goto(-100, -100)
dot(10, 0, 255, 0)
goto(-100, 100)
dot(10, 0, 0, 255)

exitonclick()
Turtle (1) B-1 3
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
colormode(255)
hideturtle()

penup()
goto(-100, 100)
dot(10, 255, 0, 0)
goto(-33, 33)
dot(10, 0, 0, 0)
goto(33, -33)
dot(10, 0, 0, 255)
goto(100, -100)
dot(10, 0, 255, 0)

exitonclick()
Turtle (1) B-1 4
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
colormode(255)
hideturtle()

penup()
goto(-100, 0)
dot(10, 0, 0, 0)
goto(-50, 0)
dot(10, 51, 51, 51)
goto(0, 0)
dot(10, 102, 102, 102)
goto(50, 0)
dot(10, 153, 153, 153)
goto(100, 0)
dot(10, 204, 204, 204)

exitonclick()
Turtle (1) B-1 5
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
colormode(255)
hideturtle()

penup()
goto(0, 80)
dot(40, 0, 0, 255)
goto(0, 40)
dot(40, 255, 0, 0)
goto(0, 0)
dot(40, 0, 0, 0)
goto(0, -40)
dot(40, 0, 255, 0)
goto(0, -80)
dot(40, 255, 0, 255)

exitonclick()
Turtle (1) B-1 6
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
colormode(255)
hideturtle()

penup()
dot(200, 0, 0, 0)
dot(160, 255, 255, 255)
dot(120, 0, 0, 0)
dot(80, 255, 255, 255)
dot(40, 0, 0, 0)

exitonclick()

turtle (1) - B-2

Turtle (1) B-2 1
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
hideturtle()

penup()
goto(-100, 0)
pendown()
goto(100, 0)

penup()
goto(0, 100)
pendown()
goto(0, -100)

exitonclick()
Turtle (1) B-2 2
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
hideturtle()

penup()
goto(-50, 50)
pendown()
goto(50, 50)
goto(50, -50)
goto(-50, -50)
goto(-50, 50)

exitonclick()
Turtle (1) B-2 3
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
hideturtle()

penup()
goto(-100, 0)
pendown()
goto(0, 100)

penup()
goto(-100, -100)
pendown()
goto(100, 100)

penup()
goto(0, -100)
pendown()
goto(100, 0)

exitonclick()
Turtle (1) B-2 4
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
hideturtle()

penup()
goto(-100, 100)
pendown()
goto(-33, 33)

penup()
goto(-100, -100)
pendown()
goto(-33, -33)

penup()
goto(100, 100)
pendown()
goto(33, 33)

penup()
goto(100, -100)
pendown()
goto(33, -33)

exitonclick()
Turtle (1) B-2 5
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
hideturtle()

penup()
goto(-50, 100)
pendown()
goto(-50, -100)

penup()
goto(50, 100)
pendown()
goto(50, -100)

penup()
goto(-100, 50)
pendown()
goto(100, 50)

penup()
goto(-100, -50)
pendown()
goto(100, -50)

exitonclick()
Turtle (1) B-2 6
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
hideturtle()

penup()
goto(-33, 100)
pendown()
goto(100, -33)

penup()
goto(-100, 33)
pendown()
goto(33, -100)

penup()
goto(-100, -33)
pendown()
goto(33, 100)

penup()
goto(-33, -100)
pendown()
goto(100, 33)

exitonclick()

turtle (1) - B-3

Turtle (1) B-3 1
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
hideturtle()

penup()
goto(-100, 50)
pendown()
goto(100, 50)
goto(100, -50)
goto(-100, -50)
goto(-100, 50)

penup()
goto(0, 50)
pendown()
goto(0, -50)

penup()
goto(-50, 0)
dot(50, 0, 0, 0)
goto(50, 0)
dot(50, 0, 0, 0)

exitonclick()
Turtle (1) B-3 2
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
hideturtle()

penup()
goto(-100, 100)
pendown()
goto(100, 100)
goto(100, -100)
goto(-100, -100)
goto(-100, 100)

penup()
goto(-66, -100)
pendown()
goto(-66, 33)
goto(66, 33)
goto(66, -100)

penup()
goto(0, 66)
dot(66, 0, 0, 0)

exitonclick()
Turtle (1) B-3 3
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
hideturtle()

penup()
goto(0, 100)
pendown()
goto(100, 0)
goto(0, -100)
goto(-100, 0)
goto(0, 100)

penup()
goto(-50, 50)
pendown()
goto(0, 0)
goto(-50, -50)

penup()
goto(-50, 0)
dot(50, 0, 0, 0)

exitonclick()
Turtle (1) B-3 4
from turtle import *

setup(250, 250, 0, 0)
screensize(120, 120)
hideturtle()

penup()
goto(-100, 0)
pendown()
goto(-50, 50)
goto(50, -50)
goto(100, 0)
goto(50, 50)
goto(-50, -50)
goto(-100, 0)

penup()
goto(0, 50)
dot(50, 0, 0, 0)
goto(0, -50)
dot(50, 0, 0, 0)

exitonclick()