Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function travel which takes a tuple of two coordinates; a starting location on a grid .x, and a starting location on a

Write a function travel which takes a tuple of two coordinates; a starting location on a grid .x, and a 

Write a function travel which takes a tuple of two coordinates; a starting location on a grid .x, and a starting location on a grid y. Your function should return a string of direction North, South, East, or West prompting if the defined coordinates belong to which moving direction. tuple that indicates the new position after following the directions starting from the given x, y. The returned string should be in the format '(x_new, y_new)'. The directions string will use 'N' to indicate increasing the y-coordinate, 'E' to indicate increasing the x-coordinate, 'S' to indicate decreasing the y-coordinate, and 'W' to indicate decreasing the x-coordinate. The case of the characters should be ignored. Any characters that are not 'N', 'E', 'W', or 'S' (ignoring letter-casing) should be ignored. 3 travel ('NWlewnw', 1, 2) # '(-1, 4)' 4 # 'N', (1, 2) => (1,3) (1,3) => (0,3) ignored (0, 3) => (1,3) 5 # 'W', 6 # '!', 7 # 'e', 8 # 'w', 9 # 'n', 10 # 'W', (1,3) => (0,3) (0,3) => (0,4) (0,4) => (-1,4) Quadrant II (-+) Quadrant III y-axis Quadrant I (+,+) Quadrant IV x-axis

Step by Step Solution

3.37 Rating (150 Votes )

There are 3 Steps involved in it

Step: 1

1 def travelcoordinates startx starty Calculates the new position on a grid based on given starting ... 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

Numerical Methods With Chemical Engineering Applications

Authors: Kevin D. Dorfman, Prodromos Daoutidis

1st Edition

1107135117, 978-1107135116

More Books

Students also viewed these Programming questions

Question

10. How can social media be used to conduct an experiment?

Answered: 1 week ago