Python Turtle Programming

Hands On No. 3 : To design a Star

To design a Star

import turtle 
import random 
color = ['purple', 'pink', 'red', 'yellow', 'green', 
       'black', 'blue', 'orange',] 
def fun(x, y): 
    global color
    r = random.randint(0, 7) 
    scr.bgcolor(color[r]) 
scr = turtle.Screen() 
scr.setup(500, 400) 
turtle.onscreenclick(fun)

turtle.bgcolor("blue")  
 
tr = turtle.Turtle()
s = 200
for i in range(100):
    tr.forward(s)
    tr.right(144)
    s = s-2

    
turtle.done()