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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Eric Redmond ,Jim Wilson

1st Edition

1934356921, 978-1934356920

More Books

Students also viewed these Databases questions

Question

Perform an Internet search. Discuss a company that uses EPLI.

Answered: 1 week ago

Question

How do you feel about employment-at-will policies? Are they fair?

Answered: 1 week ago