반응형

◆ 파이썬 거북이 꽃그리기 1 - 파이썬 거북이 목록 5번을 참고로 다음과 같은 꽃을 그려보세요

파이썬 거북이 꽃그리기

 

youtu.be/-Z0_wEhW_3E

 

[ 파이썬 거북이 꽃그리기 1 ]

import turtle as t
t.shape("turtle")
t.speed(10)
t.right(10)
t.color("green")
t.pensize("6")
for i in range(2):
    for i in range(9):
        t.forward(15)
        t.left(10)
    t.left(90)
t.left(120)
for i in range(2):
    for i in range(9):
        t.forward(15)
        t.left(10)
    t.left(90)
t.right(20)
t.forward(160)
t.color("purple")
t.pensize("4")
for i in range(7):
    for i in range(2):
        for i in range(9):
            t.forward(15)
            t.left(10)
        t.left(90)
    t.left(50)

 

 

◆ 파이썬 거북이 꽃그리기 2 - 다음과 같이 거북이를 이용해서 꽃을 그려보세요

파이썬 거북이 꽃 그리기

 

[ 파이썬 꽃그리기2 소스 ]

import turtle as t
t.shape("turtle")
t.speed(10)
t.right(10)
t.color("green")
t.pensize("6")
for i in range(2):
    for i in range(9):
        t.forward(15)
        t.left(10)
    t.left(90)
t.left(120)
for i in range(2):
    for i in range(9):
        t.forward(15)
        t.left(10)
    t.left(90)
t.pensize("7")
t.right(20)
t.forward(160)
t.color("orange")
t.right(90)
t.circle(70)
t.right(45)
t.color("yellow")
for i in range(12):
    for i in range(2):
        t.forward(38)
        t.left(360/3)
    t.left(180)
    t.right(30)

 

 

◆ 파이썬 거북이 꽃그리기3 - 다음과 같이 사각형과 원을 이용해서 꽃을 그려보세요

 

파이썬 거북이 꽃그리기

 

 

[ 파이썬 거북이 - 꽃그리기3 ]

import turtle
t = turtle

size = 30
distance = 50
angle = 20
t.speed(0)
t.shape("turtle")
t.bgcolor("blue")

n=0
while n<18:
    t.pendown()
    t.pensize(4)
    t.color("yellow")
    t.circle(size, steps=4)
    t.penup()
    t.fd(distance)
    t.lt(angle)
    n = n+1

t.setposition(5,30)

size = 50
distance = 40
n = 0
while n<18:
    t.pendown()
    t.pensize(4)
    t.color("orange")
    t.circle(size)
    t.penup()
    t.fd(distance)
    t.lt(angle)
    n = n+1
    
t.setposition(22,144)
t.color("red")

t.done()
반응형
Posted by 명문코딩컴퓨터
,