Question: In python import math import random import turtle totalScore = 0 def target(): Turtle drawing the target t = turtle.Turtle() wn = turtle.Screen() wn.bgcolor(black) t.hideturtle()

In python

In python import math import random import turtle totalScore = 0 def

import math import random import turtle

totalScore = 0

def target(): """Turtle drawing the target""" t = turtle.Turtle() wn = turtle.Screen() wn.bgcolor("black") t.hideturtle() t.speed(0) t.setposition(-350,-350) t.color("black") t.begin_fill() for i in range(4): t.forward(700) t.left(90) t.end_fill() #most outside circle worth 10 points t.setposition(0,-275) t.color("grey") t.begin_fill() t.circle(275) t.end_fill() #2nd most outter circle worth 20 points t.penup() t.setposition(0,-200) t.pendown() t.color("red") t.begin_fill() t.circle(200) t.end_fill() #3rd most outter circle worth 30 points t.penup() t.setposition(0,-125) t.pendown() t.color("orange") t.begin_fill() t.circle(125) t.end_fill() #center circle worth 50 points t.penup() t.setposition(0,-50) t.pendown() t.color("blue") t.begin_fill() t.circle(50) t.end_fill() def drawCross(pen, color, size, x, y): pen.pensize(3) pen.color(color) pen.penup() pen.goto(x-size,y-size) pen.pendown() pen.goto(x+size,y+size) pen.penup() pen.goto(x-size,y+size) pen.pendown() pen.goto(x+size,y-size)

def calculateScore(arrowx,arrowy): score = 0 totalScore = 0 distance = 0 distance = math.sqrt((arrowx ** 2) + (arrowy ** 2))

if (distance

elif (distance > 50 and distance 125 and distance 200 and distance 275): score = 0 totalScore = totalScore + score print(f" Too bad, you missed the target and you scored {score} points :(") return score

def main(): """Starts the archery game. Lets user choose how many arrows they want to fire at the target""" user = str(input("Please enter name: ")) print(f" Hello, {user}! Welcome to the wonderful game of Archery!") choice = "" target() while(choice != "q"): #Menu options print(" Please choose an option:") print(" 1. Fire one arrow") print(" 2. Fire many arrows") print(" 3. Reset the target") print(" q. Quit") choice = input(f" ") #for firing one arrow if(choice == "1"): myPen = turtle.Turtle() myPen.speed(0) myPen.shape("arrow") #Shooting the arrow arrowx= random.randint(-300,300) arrowy= random.randint(-300,300) drawCross(myPen,"cyan",10,arrowx,arrowy) calculateScore(arrowx,arrowy) myPen.hideturtle() myPen.getscreen().update() elif(choice == "2"): manyArrows = int(input(" How many arrows would you like to fire? ")) myPen = turtle.Turtle() myPen.speed(0) myPen.shape("arrow") total = 0 for x in range(manyArrows): arrowx= random.randint(-300,300) arrowy= random.randint(-300,300) drawCross(myPen, "cyan", 10, arrowx, arrowy) total+=calculateScore(arrowx, arrowy) print('Your total score =',total) elif(choice == "3"): target() elif(choice == "q"): print(f" Thanks for playing {user}!") else: print(f"I couldn't understand your choice \"{choice}\"; please try again.") if __name__ == '__main__': main()

5. Suppose you wanted your archery program to remember the points earned for each arrow individually, allowing the user to see their complete arrow history (ex: 50, 0, 20, 0, 50) Describe what you might do to store this information. 5. Suppose you wanted your archery program to remember the points earned for each arrow individually, allowing the user to see their complete arrow history (ex: 50, 0, 20, 0, 50) Describe what you might do to store this information

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!