top of page
Search

PYTHON TURTLE DESIGN

  • Writer: Jayesh Malviya
    Jayesh Malviya
  • Sep 19, 2022
  • 1 min read

INTRODUCTION

Hello, friends welcome to python learner, we create a beautiful designs in turtle. Turtle is the python module which use to create colorful designs on turtle windows.

and the second module is "colorsys" which is used to set RGB color values to change colors in design or drawing.

So, first of all, we will import both modules.


from turtle import *
import colorsys

then set the turtle window's background, turtle pen size, and turtle speed.


speed(0)
bgcolor("black")
pensize(4)

Then, type process code which creates a design.


hue = 0.0
for i in range(200):
    clr = colorsys.hsv_to_rgb(hue, 1, 1)
    pencolor(clr)
    hue += 0.01
    left(60)
    forward(i+20)
    circle(i)
    backward(i+40)

finally, run with help of mainloop() or you can also use the turtle done() function.

mainloop()

and this is the output -



Thanks for watching, if you like posts please share.


 
 
 

Comments


pythonlearner

  • Instagram
  • Facebook

©2022 by pythonlearner. Proudly created with Wix.com

bottom of page