Python Turtle Programming

Hands On No. 4 : To design Captain America’s Shield

To design Captain America’s Shield

from ast import Tuple
import turtle
import math
import time
turtle.Screen().bgcolor("black")
import random
color = ['cyan','gray','parrot green','gold','purple'] 
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)

paused = False
def unpause():
    print("unpause() called")
    global paused
    paused = False
    
    

    

def pause():
    global paused
    paused = True
    while paused:
        time.sleep(1)

marvel = turtle.Turtle()




def ankur(x, y):
    marvel.penup()
    marvel.goto(x, y)
    marvel.pendown()
    marvel.setheading(0)
    marvel.pensize(2)
    marvel.speed(10)

def golo(r, color):
    x_point = 0
    y_pont = -r
    ankur(x_point, y_pont)
    marvel.pencolor(color)
    marvel.fillcolor(color)
    marvel.begin_fill()
    marvel.circle(r)
    marvel.end_fill()
    

def paanch(r, color):
    ankur(0, 0)
    marvel.pencolor(color)
    marvel.setheading(162)
    marvel.forward(r)
    marvel.setheading(0)
    marvel.fillcolor(color)
    marvel.begin_fill()
    for i in range(5):
        marvel.forward(math.cos(math.radians(18)) * 2 * r)  
        marvel.right(144)
    marvel.end_fill()
    marvel.hideturtle()

#colors
if __name__ == '__main__':
    golo(288, 'red')
    golo(234, 'snow')
    golo(174, 'red')
    golo(114, 'blue')
    paanch(114, 'snow')

    turtle.done()