使用python做一个爱心代码

import math

from turtle import *


def heart_a(k):
    return 15 * math.sin(k) ** 3


def heart_b(k):
    return 12 * math.cos(k) - 5 * \
        math.cos(2 * k) - 2 * \
        math.cos(3 * k) - \
        math.cos(4 * k)


speed(1000)
bgcolor("black")
for i in range(6000):
    goto(heart_a(i) * 20, heart_b(i) * 20)
    for j in range(5):
        color('red')
    goto(0, 0)
done()

使用python做一个爱心代码_第1张图片

你可能感兴趣的:(python,python,开发语言)