Collection of Python Code (1)

1. RainbowCollection of Python Code (1)

import turtle as t
c = ["red", "orange", "yellow", "green", "cyan", "indigo", "violet"]
t.speed(10)
t.pensize(30)
for i in range(7):
    t.penup()
    t.goto(-150 + i * 30, 0)
    t.setheading(90)
    t.color(c[i])
    t.pendown()
    t.circle(-300 + i * 30, 180)

2. Colorful FlowersCollection of Python Code (1)

import turtle as t
import colorsys as cs
t.speed(0)
t.bgcolor("black")
for i in range(25):
    for j in range(15):
        t.color(cs.hsv_to_rgb(j / 15, i / 25, 1))
        t.right(90)
        t.circle(200 - i * 4, 90)
        t.left(90)
        t.circle(200 - i * 4, 90)
        t.right(180)
        t.circle(50, 24)

3. A Little Red Flower for YouCollection of Python Code (1)

import turtle as t
def huaban():
    t.color("red")
    t.pensize(1)
    t.begin_fill()
    t.circle(160, 60)
    t.left(60)
    t.circle(160, 30)
    t.left(60)
    t.circle(160, 60)
    t.left(90)
    t.end_fill()

def yezi(x, y, fx):
    t.color("green")
    t.pensize(1)
    t.penup()
    t.goto(x, y)
    t.setheading(fx - 45)
    t.begin_fill()
    t.pendown()
    t.circle(200, 90)
    t.left(90)
    t.circle(200, 90)
    t.end_fill()

t.penup()
t.goto(0, -200)
t.color("green")
t.pensize(10)
t.setheading(90)
t.pendown()
t.forward(400)
yezi(0, -150, 45)
yezi(0, -150, 135)
t.goto(0, 200)
for i in range(5):
    huaban()
    t.right(360 / 5)
t.dot(80, "yellow")
t.hideturtle()

4. A Little HeartCollection of Python Code (1)

import turtle as t
t.bgcolor("black")
t.penup()
t.goto(0, -100)
t.setheading(135)
t.color("red")
t.pendown()
t.begin_fill()
t.forward(141.4)
t.circle(-141.4 / 2, 180)
t.left(90)
t.circle(-141.4 / 2, 180)
t.forward(141.4)
t.end_fill()
t.hideturtle()

5. Rotating ShapesCollection of Python Code (1)

import turtle as t
from colorsys import *
t.speed(0)
t.bgcolor("black")
a = 0.7
for i in range(140):
    t.color(hsv_to_rgb(a, 1, 1))
    a += 0.003
    t.circle(180 - i, 90)
    t.left(110)
    t.circle(180 - i, 90)
    t.left(18)
t.hideturtle()

6. Rotating DartsCollection of Python Code (1)

import turtle as t
t.speed(0)
t.bgcolor("black")
t.color("aqua")
for i in range(170):
    t.right(i)
    t.circle(170, i)
    t.forward(i)
    t.right(90)

7. Taiji Yin Yang DiagramCollection of Python Code (1)

import turtle as t
t.pensize(5)
t.color("black", "black")
t.penup()
t.goto(0, -200)
t.pendown()
t.seth(0)
t.circle(200, 180)
t.begin_fill()
t.circle(200, 180)
t.circle(100, 180)
t.circle(-100, 180)
t.end_fill()
t.penup()
t.seth(0)
t.goto(0, -110)
t.color("white", "white")
t.pendown()
t.begin_fill()
t.circle(20)
t.end_fill()
t.seth(0)
t.penup()
t.goto(0, 90)
t.color("black", "black")
t.pendown()
t.begin_fill()
t.circle(20)
t.end_fill()
#t.hideturtle()

Leave a Comment