NEED A PERFECT PAPER? PLACE YOUR FIRST ORDER AND SAVE 15% USING COUPON:

python

adding comments to clarify. Write legibly. Check your code to make sure that it is computing what you want it to compute. Put a triple quote docstring in every function. Submit a handwritten hard copy next Monday at class start. Also submit a single file, quiz6_2 YourName.py, with the code for each problem and a video link showing a program run and briefly explaining your code. Make sure to announce yourself at video start. Due next Wednesday before midnight.

(10 pts) Write a boolean function, isInRect(t,xc,yc,W,H), which returns True if turtle, t, is inside or on the boundary of a rectangle of width, W, and height, H centered at xc,yc & which otherwise returns False. For this question and for the remainder of the test, assume that all rectangles have sides that are horizontal or vertical.

2. (10 pts) Write code that shows that your function from Q1 works by choosing different turtle positions relative to a rectangle with given xc,yc,W,H.

3.(20 pts) Use a while loop and use the function from Q1 as a helper function to write a function, ranWalkRects(t,x0,y0,x1,y1,W1,H1,x2,y2,W2,H2,Dz) which has turtle t start at x0,y0 outside of both rectangles execute a random walk until it is inside or on the boundary of rectangle 1 but not inside or on the boundary of rectangle 2. Assume that rectangle 1 overlaps rectangle 2 but that rectangle 1 does not lie entirely inside rectangle 2. Print out how many times the turtle moves from its starting position to the final position. Dz is the step size for the random walk. You should draw the draw the rectangles with different colors to better understand the turtle’s behavior. Making rectangle 1 bigger & increasing the turtle speed will decrease the run time. Run several test cases and convince yourself that your function works.

USE PYTHON

  • Posted: 2 hours ago
  • Due: 08/11/2019
  • Budget: $10

Looking for this or a Similar Assignment? Click below to Place your Order