A drawing of a group of turtles with different positions


python Copy code import turtle import random def desenhar_caveira(): # Initial settings Turtle.speed(0) turtle.hideturtle() turtle.pensize(3) # Desenhar a caveira turtle.penup() turtle.goto(0, -200) turtle.pendown() turtle.circle(200) # headpe # Olhos for _ in range(2): turtle.penup() x = random.randint(-120, 120) y = random.randint(30, 100) turtle.goto(x, y) turtle.pendown() turtle.begin_fill() turtle.circle(40) # olho turtle.end_fill() # Nariz turtle.penup() turtle.goto(0, 50) turtle.pendown() turtle.begin_fill() turtle.circle(20) # nariz turtle.end_fill() # Boca turtle.penup() turtle.goto(-70, -70) turtle.pendown() turtle.right(90) turtle.circle(70, 180) # boca # Ossos for _ in range(6): turtle.penup() turtle.goto(random.randint(-200, 200), random.randint(-200, 200)) turtle.pendown() turtle.goto(random.randint(-200, 200), random.randint(-200, 200)) turtle.done() def criar_opcoes(): for i in range(5): # Create 5 skull options Turtle.clear() # limpar a tela desenhar_caveira() turtle.getscreen().getcanvas().postscript(file=f"caveira_{i+1}.eps") # salvar imagem em arquivo criar_opcoes()
كلمة التلميح
نسخ
python
Copy code
import turtle
import random
def desenhar_caveira():
# Initial settings
Turtle
.
speed(0)
turtle
.
hideturtle()
turtle
.
pensize(3)
# Desenhar a caveira
turtle
.
penup()
turtle
.
goto(0
,
-200)
turtle
.
pendown()
turtle
.
circle(200) # headpe
# Olhos
for _ in range(2):
turtle
.
penup()
x = random
.
randint(-120
,
120)
y = random
.
randint(30
,
100)
turtle
.
goto(x
,
y)
turtle
.
pendown()
turtle
.
begin_fill()
turtle
.
circle(40) # olho
turtle
.
end_fill()
# Nariz
turtle
.
penup()
turtle
.
goto(0
,
50)
turtle
.
pendown()
turtle
.
begin_fill()
turtle
.
circle(20) # nariz
turtle
.
end_fill()
# Boca
turtle
.
penup()
turtle
.
goto(-70
,
-70)
turtle
.
pendown()
turtle
.
right(90)
turtle
.
circle(70
,
180) # boca
# Ossos
for _ in range(6):
turtle
.
penup()
turtle
.
goto(random
.
randint(-200
,
200)
,
random
.
randint(-200
,
200))
turtle
.
pendown()
turtle
.
goto(random
.
randint(-200
,
200)
,
random
.
randint(-200
,
200))
turtle
.
done()
def criar_opcoes():
for i in range(5): # Create 5 skull options
Turtle
.
clear() # limpar a tela
desenhar_caveira()
turtle
.
getscreen()
.
getcanvas()
.
postscript(file=f"caveira_{i+1}
.
eps") # salvar imagem em arquivo
criar_opcoes()
معلومات
0 تعليق
0
0
0