Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def find _ coordinates ( movements ) : x , y = 0 , 0 for move in movements: if move = = ' N

def find_coordinates(movements):
x, y =0,0
for move in movements:
if move =='N':
y +=1
elif move =='S':
y -=1
elif move =='E':
x +=1
elif move =='W':
x -=1
return (x, y)
# Test the function with the given examples
print(find_coordinates('NNE')) # Output: (1,2)
print(find_coordinates('NNEEENNW')) # Output: (2,4)
print(find_coordinates('WNENWNSNN')) # Output: (-1,4)
print(find_coordinates('EESSENNESE')) # Output: (5,-1)
print(find_coordinates('WEENEWE')) # Output: (2,1)
print(find_coordinates('NWEWWNSWW')) # Output: (-4,1)

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

More Books

Students also viewed these Databases questions

Question

(6) If E(X) = 1 and E(X2) = 2, then the variance is 2.

Answered: 1 week ago

Question

Choosing Your Topic Researching the Topic

Answered: 1 week ago

Question

The Power of Public Speaking Clarifying the

Answered: 1 week ago