파이썬 체험하기

import turtle as t import random t.shape("turtle") t.speed(0) colors=["gold","orange","light coral","deep sky blue","cyan","purple","magenta","green","dark red"] t.pensize(2) t.bgcolor("black") for i in range(10000): t.forward(i%100) t.color(colors[i%9]) t.right(random.randint(85, 95)) if i%100==0 and i!=0: t.right(90) t.forward(10) t.right(120) t.forward(20) t.right(120) t.forward(20) t.right(120) t.forward(10) t.penup() t.goto ((random.randint(-1000,1000)),(random.randint(-350,350))) t.pendown()

 

 

 

장미꽃

import turtle as t t.bgcolor("black") t.color("pink") t.speed(0) for i in range(200): t.forward(i) t.left(65) t.color("lightblue") t.setheading(270) for i in range(50): t. pensize(25 - i/2) t. forward(i/4)

 

 

 

원(1)

import turtle t=turtle.Turtle() colors=["red", "orange", "yellow", "silver", "blue", "yellow green", "sky blue", "violet", "black", "gold"] t.speed(1000) for x in range (10): t.color(colors[x]) t.right(36) y=20 while y<50: t.circle(y) y=y+1

 

 

 

달팽이무늬

import turtle t = turtle.Turtle() t.left(60) for x in range(1000) : for y in range(5) : t.forward(100-0.5*x) t.right(72) t.right(5)

 

 

 

원(2)

import turtle t = turtle.Turtle() colors=["red", "blue", "pink", "yellow", "black", "green"] n=1 t.speed(1000) while n<500: t.color(colors[n%6]) t.pensize(n/100) t.circle(n) n=n+1

 

 

랜덤

 

초등2기/한효인 2023-10-28 20:40:48