How to Make Cool Art with Python Turtle
Hi everyone and here's just a quick tutorial on how to create cool designs with Python Turtle in just a few lines of code!
#This is a comment import turtle #import the turtle module bob = turtle.Turtle() #create a turtle named bob
Import the turtle module and create a turtle (in this case the turtle is called bob, but you can name the turtle whatever you want).
for i in range(360): #run the code 360 times bob.forward(47) #forward 47 pixels bob.left(103) #turn left 103 degrees bob.circle(80,90) #draw a circle with a radius of 80 for 90 degrees bob.circle(60,120)
Add a for loop with some random turtle code like the ones listed above. You can find a list of turtle commands here.
Add some colors to your drawing. The code to set the color of bob to green is
bob.color("green"). You may also use RGB:
bob.color((0,255,0)). You can change the turtle's color as many times as you like. Change the background color this way:
Test out your code. If it doesn't look right try again with different values. Repeat the process until you have a perfect turtle drawing. Tip: make bob invisible with
bob.hideturtle() if that looks better. He will still be able to draw.
Make the turtle draw faster. Setting the speed to the highest with
bob.speed(0) will work, but sometimes it will still take a long time to draw. Putting the drawing code between
bob.tracer(1) makes the whole thing really fast.
import turtle bob=turtle.Turtle() s=turtle.Screen() s.bgcolor("black") bob.hideturtle() for i in range(180): bob.tracer(0) bob.color("Yellow") bob.forward(47) bob.left(103) bob.color("Cyan") bob.circle(80,90) bob.color("deeppink") bob.circle(60,120) bob.tracer(1)
Great! Now you have a nice turtle drawing to stare at all day!
First, you need to understand Turtle, which is a drawing board-like Python function that lets us tell the turtle to draw all over it! We can use functions like turtle.forward (…) and turtle.right (…) that can move the turtle. Commonly used methods for turtles are: Method Parameter Description
It is like a basic foundation in various sciences of plastic surgery here and cosmetic surgery, which takes the first step and then step by step!