import turtle
import random
## Global Variable Part ##
swidth, sheight, pSize = 500, 500, 3
r, g, b, angle, dist, = 0, 0, 0, 30, 5 # Set the angle to 30 degrees
## Main function part ##
turtle.title ('drawing a conch with a turtle')
turtle.shape('turtle')
turtle.pensize(pSize)
turtle.setup(width = swidth + 30, height = sheight + 30)
turtle.screensize(swidth, sheight)
for i in range(80) :
turtle.pencolor("red")
turtle.pencolor("orange")
turtle.pencolor("yellow")
turtle.pencolor("green")
turtle.pencolor("blue")
turtle.pencolor("navy")
turtle.pencolor("purple")
turtle.pencolor("black")
dist + = 1 # Increase the length of the line you draw by 1
turtle.forward(dist)
turtle.left(angle) # 30 degrees to the left
turtle.done()
Let's start with red I want to change it to black, how can I apply it??
python
You can divide the case according to i.
import turtle
import random
## Global Variable Part ##
swidth, sheight, pSize = 500, 500, 3
r, g, b, angle, dist, = 0, 0, 0, 30, 5 # Set the angle to 30 degrees
## Main function part ##
turtle.title ('drawing a conch with a turtle')
turtle.shape('turtle')
turtle.pensize(pSize)
turtle.setup(width = swidth + 30, height = sheight + 30)
turtle.screensize(swidth, sheight)
for i in range(80) :
if i % 8 == 1:
turtle.pencolor("red")
elif i % 8 == 2:
turtle.pencolor("orange")
elif i % 8 == 3:
turtle.pencolor("yellow")
elif i % 8 == 4:
turtle.pencolor("green")
elif i % 8 == 5:
turtle.pencolor("blue")
elif i % 8 == 6:
turtle.pencolor("navy")
elif i % 8 == 7:
turtle.pencolor("purple")
elif i % 8 == 0:
turtle.pencolor("black")
dist + = 1 # Increase the length of the line you draw by 1
turtle.forward(dist)
turtle.left(angle) # 30 degrees to the left
turtle.done()
© 2024 OneMinuteCode. All rights reserved.