Turtle Graphic Python
Author name: Minh Nguyen
In Python, turtle graphics provides a representation of a physical “turtle” (a little robot with a pen) that draws on a sheet of paper on the floor. This is heart graphic from CodingWithNoman on YouTube.
This is the code to make this graphic.
import math
from turtle import *
def hearta(k):
return 15*math.sin(k)**3
def heartb(k):
return 12*math.cos(k)-5*\
math.cos(2*k)-2*\
math.cos(3*k)-\
math.cos(4*k)
speed(1000)
bgcolor('#f8b595')
for i in range(6000):
goto(hearta(i)*20, heartb(i)*20)
for j in range(5):
color('#f67280')
goto(0,0)
done()
After you play it, you will have your graphic.
You can change the color in the code I highlighted above. Here are some images I changed the colors.
If you interested about turtle graphic python. You can go to CodingWithNoman to see more graphic.😊