Write a function travel which takes a tuple of two coordinates; a starting location on a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
1 def travelcoordinates startx starty Calculates the new position on a grid based on given starting ... View the full answer
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date:
Students also viewed these programming questions
-
In an experiment conducted online at the University of Mississippi, study participants are asked to react a stimulus. In one experiment, the participant must press a key upon seeing a blue screen....
-
Ivanhoe Greenhouses Ltd. signed a 15-year, 6.5%, $940,000 loan on September 30, 2024, to help finance a new state-of-the-art greenhouse with an associated renewable energy source. The loan terms...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
For data Tables in an Oracle Server database, a blank field must be a. Indicated by NULL Avoided b. Kept as a blank c. Indicated either by NULL or a blank d. Indicated by NULL
-
The next table shows the results from The American Freshman: National Norms Fall 2015 of a question posed to 141,000 college freshmen. Consider the experiment of selecting a student at random from...
-
Subway, with more than 20,000 outlets in the U.S., is planning for a new restaurant in Buffalo, New York. Three locations are being considered. The following table gives the factors for each site....
-
Discuss why entry into the assurance services market is important to public accounting firms.
-
Dorothys pastries are freshly baked and sold at several specialty shops throughout Perth. When they are a day old, they must be sold at reduced prices. Daily demand is distributed as follows: Demand...
-
1. In Figure 1, draw a FBD of the tennis ball (at that exact spot) and then calculate the tension in the rope. Use 50 m/s for velocity and a radius of 0.8 m. Provide me with a rope that you would...
-
Whitestone Company produces two subassemblies, JR-14 and RM-13, used in manufacturing trucks. The company is currently using an absorption costing system that applies overhead based on direct-labor...
-
You are to implement a Webale Chess game as a GUI-based Java Application. You do not have to implement a computer player -it can just be a two human player game. Webale Chess is played on a 7x8...
-
As Aristotle famously stated, Character may almost be called the most effective means of persuasion. Do you think this is true in todays business world? Explain your viewpoints with three or four...
-
Think about a recent situation at school or work in which you observed a serious instance of emotional hijacking. Based on this situation, do the following: A. Briefly explain what happened. Who was...
-
Choose three topics of interest that you could research. Write three specific research objectives that could provide a clear direction for you to collect primary data or gather secondary research.
-
Think about a recent miscommunication you had with someone. Ideally, select an in-depth conversation that occurred in the workplace or at school. Based on this conversation, do the following: A....
-
Think about a recent movie or TV episode you observed. Select a scene that involved a miscommunication. Ideally, it should include a conversation that might occur in a workplace. Based on this...
-
Bean defaulted on a promissory note payable to Gray Co. The note was secured by a piece of equipment owned by Bean. Gray perfected its security interest on May 29 Bean had also pledged the same...
-
Assume Eq. 6-14 gives the drag force on a pilot plus ejection seat just after they are ejected from a plane traveling horizontally at 1300 km/h. Assume also that the mass of the seat is equal to the...
-
Write the determinant of the following 33 matrix A as a sum of the determinants of 2 2 matrices using co-factor expansion on the second row (i = 2): A = 635 215 23 2
-
This problem deals with the numerical analysis of the solution to This is a separable ordinary differential equation with the solution The exact solution is denoted as y for future reference. (a) We...
-
For a packed bed, the Ergun equation provides a relationship between the pressure drop per unit length and the properties of the bed, where is the fluid viscosity, v 0 is the superficial velocity, D...
-
Discuss the approach you would take to building a system for playing Scrabble or another word game of the sort. What limitations does your system have? How likely do you think it is that your system...
-
Discuss the current state of the art of game-playing computer systems in relation to the following games: chess, checkers, Go, bridge, Othello, tic-tac-toe. What advances are likely in the near...
-
What problems did the developers of Chinook face? What new techniques did they add to simple Minimax with alpha-beta pruning? Would these techniques extend well to other games?
Study smarter with the SolutionInn App