A robot moves in a 2D lattice. The robot can only move north (N), south (S), east (E), and west (W) by a certain number of steps. Assume that the robot always starts at (0,0), and that the x axis is...


A robot moves in a 2D lattice. The robot can only move north (N), south (S), east (E), and west (W)<br>by a certain number of steps. Assume that the robot always starts at (0,0), and that the x axis is<br>oriented east, while the y axis is oriented north. Write a Python function that, given a set of moves,<br>calculates the final position of the robot.<br>For example, if the set of moves provided as input is:<br>N 2<br>E 4<br>S 1<br>W 3<br>then the final position of the robot is (1,1). The integer that follows a move is always positive.<br>Follow this code skeleton:<br>def robot_move (moves):<br>X = 0<br>y = 0<br># your code here<br>return (x,y)<br>The moves are provided as an array of tuples. The array can have any number of moves in any order.<br>The example above is passed as input as follows:<br>[('N',2), ('E',4), ('S',1), ('W',3)]<br>

Extracted text: A robot moves in a 2D lattice. The robot can only move north (N), south (S), east (E), and west (W) by a certain number of steps. Assume that the robot always starts at (0,0), and that the x axis is oriented east, while the y axis is oriented north. Write a Python function that, given a set of moves, calculates the final position of the robot. For example, if the set of moves provided as input is: N 2 E 4 S 1 W 3 then the final position of the robot is (1,1). The integer that follows a move is always positive. Follow this code skeleton: def robot_move (moves): X = 0 y = 0 # your code here return (x,y) The moves are provided as an array of tuples. The array can have any number of moves in any order. The example above is passed as input as follows: [('N',2), ('E',4), ('S',1), ('W',3)]

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here