Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSE class requires us to write a program, this is how far i got, and I want to know how do I do this next

CSE class requires us to write a program, this is how far i got, and I want to know how do I do this next step.

image text in transcribed

image text in transcribed

6.1.4. Function hitPond Summary The hitPond function will be used in order to determine whether or not a cannon shot hit the pond. It's a simple function that returns either True or False. Do this Write a new function called hitPond that has these parameters: 1. the x location of the shot the y location of the shot 2. Name the two parameter variables appropriately. You could call them x and y, or shotX and shotY. It's up to you. Note that there is no one single correct way to name parameters, as long as the names are short but descriptive. Use the Pythagorean theorem to determine if the shot landed within the pond (i.e., if the distance from POND X, POND Y to shotX, shotY is less than the pond radius POND_R) This function returns True if the shot fell in the pond or False if it did not. You will have to figure out a few things in order to implement the Pythagorean theorem in Python. Use Google. Use your brain. Hint: you will need to use the sqrt function from the math module. import math import random import tkinter # dimensions of the field FIELD. W = 600 FIELDH600 # position and size of the pond POND_X- 300 PONDY300 POND_R150 # number of shots to fire NUM_SHOTS100 def drawcircle(canvas, x, y, r, outline 'black, fill-whte: x2 - x + r canvas.create_oval(x1, yl, x2, y2, fill-fil1, outline-outline) def drawPond (canvas): drawcircle (canvas, POND_X, POND_Y, POND_R, 'blue) def initwindow(title, width, height) master - tkinter.Tk ( master.title(title) canvas-tkinter.Canvas (master, width-width, height-height) canvas.pack O return canvas def mainQ: canvas initwindow("Monte Carlo Simulation", FIELD_W, FIELD_H drawPond (canvas) if _name_-main__': mainO tkinter.mainloop )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

LO1 Understand risk management and identify its components.

Answered: 1 week ago