Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a JES program (minimum of one function) that prompts the user for the abov

ID: 3811520 • Letter: W

Question

Write a JES program (minimum of one function) that prompts the user for the above picture(maze.jpg).Use the ec2_turtles.py to get you started. The program will have the turtle start at "Start Turtle Here", touch the last three non-repeating numbers of your xNumber, and end at "End Turtle Here".(For example: if your xNumber is x50440, You Would have the turtle go from start to0 to 4 to end) Rules: Lines MAY NOT OVERLAP or CROSS Your turtle cannot touch any other numbers. The turtle most go around those numbers.

Explanation / Answer

First, we load JES and create the following function to prompt user for the maze image.

# function to choose and display maze.jpg using file chooser

def displayImage():

print "Choose image of maze"

#/displays file choosing dialog box to user

fille=pickAFile()

#Displays the pathname of chosen file

print file

#Creates a picture object

pic=makePicture(file)

show(pic)

Now, coming to the python program to guide the turtle in the maze image.

Last three numbers of chosen Xnumber are 033 .We have to touch last three non repeating numbers of Xnumber hence, we choose the path x2033 i.e. the turtle goes from x to 2 to 0 and then to 3 and to end.

import turtle

import maze

myPath=turtle.Turtle()

#shape of turtle given to the turtle pointer

turtle.shape("turtle")

# start of maze

myPath.forward(30)

myPath.left(90)

myPath.forward(60)

myPath.right(120)

myPath.forward(60)

myPath.right(90)

myPath.forward(60)

First, let us assume the maze isof size 100x100 cells.

The turtle starts and goes forward(30) in the downward direction towards 2.

Next, the turtle rotates left(90) to go towards 0.

Then , it moves forward(60) to go towards 0 in the upper right direction.

Next, it rotates(120) to go towards 3 in the downward direction.

It goes forward(60) towards 3

It rotates(90) again to go towards the end.

Finally, it moves forward(60) to reach the end, thus avoiding other numbers and not crossing previous lines in its path.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote