Wednesday, 2 March 2022

An archery target consists of a central circle of yellow surrounded by concentric rings of red, blue, black and white

 CODE :

An archery target consists of a central circle of yellow surrounded by concentric rings of red, blue, black and white. Each ring has the same width, which is the same as the radius of the yellow circle. Write a program called target.py that draws this target.

o Use a list of colors and a for loop to draw the target

o Hint: objects drawn later will appear on top of objects drawn earlier

o The output of the program should look like this:

SCREENSHOT



SAVE this file as target.py

from graphics import *

def main():

    win = GraphWin('Archery Target',300,300)

    center = Point(150,150)


    w = Circle(center, 100)

    w.setFill('white')

    w.draw(win)


    bl = Circle(center, 80)

    bl.setFill('black')

    bl.draw(win)


    b = Circle(center, 60)

    b.setFill('blue')

    b.draw(win)


    r = Circle(center, 40)

    r.setFill('red')

    r.draw(win)


    y = Circle(center, 20)

    y.setFill('yellow')

    y.draw(win)


    win.getMouse() # pause for click in window

    win.close()


main()

No comments:

Post a Comment