I need following assignments completed and need them completed inside the python coding file. Need to follow the instructions from the last code put on there. Do not edit or erase any other code that was already on there.
import time import math from graphics import * MISS = 0 BULLSEYE = 1 RING1 = 2 RING2 = 3 RING3 = 4 RING4 = 5 TARGET_CENTER = Point(100, 75) RADIUS = [0, 15, 30, 45, 60, 75, 90] RADIUS_COLOR = ['black', 'red', 'white', 'blue', 'white', 'red'] #...................... 1 ...................................... # The animated arrow is missing the target. Help me to adjust # the code between the lines below so that the arrow hits the target! def main(): ''' Main Program to draw a target and arrow onto a window ''' # Build the window with the title and size specified win = GraphWin('Target', 200, 150) #------------------------------------- arrowLocation = Point(200, 75) for arrowX in range(int(arrowLocation.getX()), -1, -10): background = Rectangle(Point(0, 0), Point(win.getWidth(), win.getHeight())) background.setFill('light grey') background.draw(win) drawTarget(win, MISS) arrowLocation = Point (arrowX, arrowLocation.getY()) drawArrow(win, arrowLocation) time.sleep(1/30) #------------------------------------- #Draw it one list time to reflect where it hit drawTarget(win, determineHit(arrowLocation)) drawArrow(win, arrowLocation) #........................ 2 ......................... # Replace the code between the lines with loop instead of the if/else logic def determineHit(strikePoint): ''' Determine where on the target the strike points hit strikePoint - the impact of the arrow returns one of the constants above ''' x = strikePoint.getX() y = strikePoint.getY() distance = math.sqrt((TARGET_CENTER.getX() - x)**2 + (TARGET_CENTER.getY() - y)**2) #------------------------------------- if distance < radius[bullseye]:="" return="" bullseye="" elif="" distance="">< radius[ring1]:="" return="" ring1="" elif="" distance="">< radius[ring2]:="" return="" ring2="" elif="" distance="">< radius[ring3]:="" return="" ring3="" elif="" distance="">< radius[ring4]: return ring4 else: return miss #------------------------------------- #........................ 3 ......................... # we can refactor the code we wrote last time to make it more flexible. # rewrite the drawtarget function to use a loop instead of a long if/else chain def drawtarget(win, hit): ''' draw a ringed target onto the provided window win - the target window for the arrow hit - the index of the ring that was hit (using constants above) ''' ring4 = circle(target_center, radius[ring4]) if hit == ring4: ring4.setfill("green") else: ring4.setfill("red") ring4.draw(win) ring3 = circle(target_center, radius[ring3]) if hit == ring3: ring3.setfill("green") else: ring3.setfill("white") ring3.draw(win) ring2 = circle(target_center, radius[ring2]) if hit == ring2: ring2.setfill("green") else: ring2.setfill("blue") ring2.draw(win) ring1 = circle(target_center, radius[ring1]) if hit == ring1: ring1.setfill("green") else: ring1.setfill("white") ring1.draw(win) bullseye = circle(target_center, radius[bullseye]) if hit == bullseye: bullseye.setfill("green") else: bullseye.setfill("red") bullseye.draw(win) def drawarrow(win, startpoint): ''' draw an arrow onto the provided window win - the target window for the arrow startpoint - where to draw the tip of the arrow ''' x = startpoint.getx() y = startpoint.gety() head = polygon(point(x, y), point(x + 13, y - 5), point(x + 13, y + 5)) head.setfill("grey") head.draw(win) shaft = line(point(x + 60, y), point(x + 13, y)) shaft.setwidth(3) shaft.setoutline("brown") shaft.draw(win) fletching = polygon(point(x + 60, y), point(x + 65, y - 5), point(x + 85, y - 5), point(x + 80, y), point(x + 85, y + 5), point(x + 65, y + 5)) fletching.setfill("yellow") fletching.draw(win) main() def total(values): ''' add up all the numbers in the list values - a list of numbers returns the total ''' return 0 def mean(values): ''' compute the mean of the values in the list values - a list of numbers returns the mean ''' return 0 def count(values, find): ''' count the number of occurances of the provided number within the list values - a list of numbers find - the number to count returns the number of instances ''' return 0 def median(values): ''' compute the median value of the list values - a list of numbers ''' # the median is the 'middle value' of the list # if the list is odd, it is that value directly # if the list is even, it is the average of the middle two values # hint: to sort your list, use the line # values.sort() return 0 def largest(values): ''' find the largest value in the list values - a list of numbers ''' return 0 def smallest(values): ''' find the smallest value in the list values - a list of numbers ''' return 0 def tentimes(values): ''' see if any value in this list is 10 times greater than another value in the list, but watch out for 0! values - a list of numbers ''' # hint: the wrong logic will make any value look 10 times zero return false #======================================================================= # do not edit anything below here def checkequals(check, expected, inputlist, message): if check != expected: print(message, "your code returned ", check, " but should have returned", expected, "for input", inputlist) return false return true def tester(): totalstatus = true; basic = [2, 5, 10, 15] negative = [0, -5, -10] mixed = [-5, -1, 0, 1, 5] empty = [] testerror = "total() failed:" status = true status &= checkequals(total(basic), 32, basic, testerror) status &= checkequals(total(negative), -15, negative, testerror) status &= checkequals(total(mixed), 0, mixed, testerror) status &= checkequals(total(empty), 0, empty, testerror) totalstatus = totalstatus and status print("total() ", "passed" if status else "failed") testerror = "mean()" status = true status &= checkequals(mean(basic), 8.0, basic, testerror) status &= checkequals(mean(negative), -5.0, negative, testerror) status &= checkequals(mean(mixed), 0.0, mixed, testerror) status &= checkequals(mean(empty), 0.0, empty, testerror) totalstatus = totalstatus and status print("mean() ", "passed" if status else "failed") testerror = "count()" status = true multiple = [0, 5, 2, 3, 5, 2, -5, 5] status &= checkequals(count(basic, 10), 1, basic, testerror) status &= checkequals(count(negative, 7), 0, multiple, testerror) status &= checkequals(count(multiple, 5), 3, multiple, testerror) status &= checkequals(count(empty, 0), 0, radius[ring4]:="" return="" ring4="" else:="" return="" miss="" #-------------------------------------="" #........................="" 3="" .........................="" #="" we="" can="" refactor="" the="" code="" we="" wrote="" last="" time="" to="" make="" it="" more="" flexible.="" #="" rewrite="" the="" drawtarget="" function="" to="" use="" a="" loop="" instead="" of="" a="" long="" if/else="" chain="" def="" drawtarget(win,="" hit):="" '''="" draw="" a="" ringed="" target="" onto="" the="" provided="" window="" win="" -="" the="" target="" window="" for="" the="" arrow="" hit="" -="" the="" index="" of="" the="" ring="" that="" was="" hit="" (using="" constants="" above)="" '''="" ring4="Circle(TARGET_CENTER," radius[ring4])="" if="" hit="=" ring4:="" ring4.setfill("green")="" else:="" ring4.setfill("red")="" ring4.draw(win)="" ring3="Circle(TARGET_CENTER," radius[ring3])="" if="" hit="=" ring3:="" ring3.setfill("green")="" else:="" ring3.setfill("white")="" ring3.draw(win)="" ring2="Circle(TARGET_CENTER," radius[ring2])="" if="" hit="=" ring2:="" ring2.setfill("green")="" else:="" ring2.setfill("blue")="" ring2.draw(win)="" ring1="Circle(TARGET_CENTER," radius[ring1])="" if="" hit="=" ring1:="" ring1.setfill("green")="" else:="" ring1.setfill("white")="" ring1.draw(win)="" bullseye="Circle(TARGET_CENTER," radius[bullseye])="" if="" hit="=" bullseye:="" bullseye.setfill("green")="" else:="" bullseye.setfill("red")="" bullseye.draw(win)="" def="" drawarrow(win,="" startpoint):="" '''="" draw="" an="" arrow="" onto="" the="" provided="" window="" win="" -="" the="" target="" window="" for="" the="" arrow="" startpoint="" -="" where="" to="" draw="" the="" tip="" of="" the="" arrow="" '''="" x="startPoint.getX()" y="startPoint.getY()" head="Polygon(Point(x," y),="" point(x="" +="" 13,="" y="" -="" 5),="" point(x="" +="" 13,="" y="" +="" 5))="" head.setfill("grey")="" head.draw(win)="" shaft="Line(Point(x" +="" 60,="" y),="" point(x="" +="" 13,="" y))="" shaft.setwidth(3)="" shaft.setoutline("brown")="" shaft.draw(win)="" fletching="Polygon(Point(x" +="" 60,="" y),="" point(x="" +="" 65,="" y="" -="" 5),="" point(x="" +="" 85,="" y="" -="" 5),="" point(x="" +="" 80,="" y),="" point(x="" +="" 85,="" y="" +="" 5),="" point(x="" +="" 65,="" y="" +="" 5))="" fletching.setfill("yellow")="" fletching.draw(win)="" main()="" def="" total(values):="" '''="" add="" up="" all="" the="" numbers="" in="" the="" list="" values="" -="" a="" list="" of="" numbers="" returns="" the="" total="" '''="" return="" 0="" def="" mean(values):="" '''="" compute="" the="" mean="" of="" the="" values="" in="" the="" list="" values="" -="" a="" list="" of="" numbers="" returns="" the="" mean="" '''="" return="" 0="" def="" count(values,="" find):="" '''="" count="" the="" number="" of="" occurances="" of="" the="" provided="" number="" within="" the="" list="" values="" -="" a="" list="" of="" numbers="" find="" -="" the="" number="" to="" count="" returns="" the="" number="" of="" instances="" '''="" return="" 0="" def="" median(values):="" '''="" compute="" the="" median="" value="" of="" the="" list="" values="" -="" a="" list="" of="" numbers="" '''="" #="" the="" median="" is="" the="" 'middle="" value'="" of="" the="" list="" #="" if="" the="" list="" is="" odd,="" it="" is="" that="" value="" directly="" #="" if="" the="" list="" is="" even,="" it="" is="" the="" average="" of="" the="" middle="" two="" values="" #="" hint:="" to="" sort="" your="" list,="" use="" the="" line="" #="" values.sort()="" return="" 0="" def="" largest(values):="" '''="" find="" the="" largest="" value="" in="" the="" list="" values="" -="" a="" list="" of="" numbers="" '''="" return="" 0="" def="" smallest(values):="" '''="" find="" the="" smallest="" value="" in="" the="" list="" values="" -="" a="" list="" of="" numbers="" '''="" return="" 0="" def="" tentimes(values):="" '''="" see="" if="" any="" value="" in="" this="" list="" is="" 10="" times="" greater="" than="" another="" value="" in="" the="" list,="" but="" watch="" out="" for="" 0!="" values="" -="" a="" list="" of="" numbers="" '''="" #="" hint:="" the="" wrong="" logic="" will="" make="" any="" value="" look="" 10="" times="" zero="" return="" false="" #="======================================================================" #="" do="" not="" edit="" anything="" below="" here="" def="" checkequals(check,="" expected,="" inputlist,="" message):="" if="" check="" !="expected:" print(message,="" "your="" code="" returned="" ",="" check,="" "="" but="" should="" have="" returned",="" expected,="" "for="" input",="" inputlist)="" return="" false="" return="" true="" def="" tester():="" totalstatus="True;" basic="[2," 5,="" 10,="" 15]="" negative="[0," -5,="" -10]="" mixed="[-5," -1,="" 0,="" 1,="" 5]="" empty="[]" testerror="total() failed:" status="True" status="" &="checkEquals(total(basic)," 32,="" basic,="" testerror)="" status="" &="checkEquals(total(negative)," -15,="" negative,="" testerror)="" status="" &="checkEquals(total(mixed)," 0,="" mixed,="" testerror)="" status="" &="checkEquals(total(empty)," 0,="" empty,="" testerror)="" totalstatus="totalStatus" and="" status="" print("total()="" ",="" "passed"="" if="" status="" else="" "failed")="" testerror="mean()" status="True" status="" &="checkEquals(mean(basic)," 8.0,="" basic,="" testerror)="" status="" &="checkEquals(mean(negative)," -5.0,="" negative,="" testerror)="" status="" &="checkEquals(mean(mixed)," 0.0,="" mixed,="" testerror)="" status="" &="checkEquals(mean(empty)," 0.0,="" empty,="" testerror)="" totalstatus="totalStatus" and="" status="" print("mean()="" ",="" "passed"="" if="" status="" else="" "failed")="" testerror="count()" status="True" multiple="[0," 5,="" 2,="" 3,="" 5,="" 2,="" -5,="" 5]="" status="" &="checkEquals(count(basic," 10),="" 1,="" basic,="" testerror)="" status="" &="checkEquals(count(negative," 7),="" 0,="" multiple,="" testerror)="" status="" &="checkEquals(count(multiple," 5),="" 3,="" multiple,="" testerror)="" status="" &="checkEquals(count(empty," 0),=""> radius[ring4]: return ring4 else: return miss #------------------------------------- #........................ 3 ......................... # we can refactor the code we wrote last time to make it more flexible. # rewrite the drawtarget function to use a loop instead of a long if/else chain def drawtarget(win, hit): ''' draw a ringed target onto the provided window win - the target window for the arrow hit - the index of the ring that was hit (using constants above) ''' ring4 = circle(target_center, radius[ring4]) if hit == ring4: ring4.setfill("green") else: ring4.setfill("red") ring4.draw(win) ring3 = circle(target_center, radius[ring3]) if hit == ring3: ring3.setfill("green") else: ring3.setfill("white") ring3.draw(win) ring2 = circle(target_center, radius[ring2]) if hit == ring2: ring2.setfill("green") else: ring2.setfill("blue") ring2.draw(win) ring1 = circle(target_center, radius[ring1]) if hit == ring1: ring1.setfill("green") else: ring1.setfill("white") ring1.draw(win) bullseye = circle(target_center, radius[bullseye]) if hit == bullseye: bullseye.setfill("green") else: bullseye.setfill("red") bullseye.draw(win) def drawarrow(win, startpoint): ''' draw an arrow onto the provided window win - the target window for the arrow startpoint - where to draw the tip of the arrow ''' x = startpoint.getx() y = startpoint.gety() head = polygon(point(x, y), point(x + 13, y - 5), point(x + 13, y + 5)) head.setfill("grey") head.draw(win) shaft = line(point(x + 60, y), point(x + 13, y)) shaft.setwidth(3) shaft.setoutline("brown") shaft.draw(win) fletching = polygon(point(x + 60, y), point(x + 65, y - 5), point(x + 85, y - 5), point(x + 80, y), point(x + 85, y + 5), point(x + 65, y + 5)) fletching.setfill("yellow") fletching.draw(win) main() def total(values): ''' add up all the numbers in the list values - a list of numbers returns the total ''' return 0 def mean(values): ''' compute the mean of the values in the list values - a list of numbers returns the mean ''' return 0 def count(values, find): ''' count the number of occurances of the provided number within the list values - a list of numbers find - the number to count returns the number of instances ''' return 0 def median(values): ''' compute the median value of the list values - a list of numbers ''' # the median is the 'middle value' of the list # if the list is odd, it is that value directly # if the list is even, it is the average of the middle two values # hint: to sort your list, use the line # values.sort() return 0 def largest(values): ''' find the largest value in the list values - a list of numbers ''' return 0 def smallest(values): ''' find the smallest value in the list values - a list of numbers ''' return 0 def tentimes(values): ''' see if any value in this list is 10 times greater than another value in the list, but watch out for 0! values - a list of numbers ''' # hint: the wrong logic will make any value look 10 times zero return false #======================================================================= # do not edit anything below here def checkequals(check, expected, inputlist, message): if check != expected: print(message, "your code returned ", check, " but should have returned", expected, "for input", inputlist) return false return true def tester(): totalstatus = true; basic = [2, 5, 10, 15] negative = [0, -5, -10] mixed = [-5, -1, 0, 1, 5] empty = [] testerror = "total() failed:" status = true status &= checkequals(total(basic), 32, basic, testerror) status &= checkequals(total(negative), -15, negative, testerror) status &= checkequals(total(mixed), 0, mixed, testerror) status &= checkequals(total(empty), 0, empty, testerror) totalstatus = totalstatus and status print("total() ", "passed" if status else "failed") testerror = "mean()" status = true status &= checkequals(mean(basic), 8.0, basic, testerror) status &= checkequals(mean(negative), -5.0, negative, testerror) status &= checkequals(mean(mixed), 0.0, mixed, testerror) status &= checkequals(mean(empty), 0.0, empty, testerror) totalstatus = totalstatus and status print("mean() ", "passed" if status else "failed") testerror = "count()" status = true multiple = [0, 5, 2, 3, 5, 2, -5, 5] status &= checkequals(count(basic, 10), 1, basic, testerror) status &= checkequals(count(negative, 7), 0, multiple, testerror) status &= checkequals(count(multiple, 5), 3, multiple, testerror) status &= checkequals(count(empty, 0), 0,>