subject

A certain robot can perform only 4 types of movement. It can move either up or down or left or right. These movements are represented by ’U’, ’D’, ’L’, ’R’. Assume all these movements to be of unit distance. Write a function named theRoundTrip that takes all the movements the robot made in a day as input and output True of bool type if the robot returned to its starting position after its journey. Otherwise return False. If the input is bad print the message "bad input" and return to solve the next question.

Have a main function from which the answer to questions are retrieved and run the program as a whole.

Examples:
Test Case 1:
input: movement = [’U’, ’L’, ’D’, ’R’]
output: True
Explanation: In a 2D plane a unit movement up by 1, left by 1, down by 1 and right by 1 would result in arriving at the starting posistion. So we return True.

Test Case 2:
input: movement = [’U’, ’U’, ’R’, ’L’, ’D’, ’R’]
output: False
Explanation: After traversing this movement we see that we have not arrived at the start- ing position. So we return False.

Test Case 3:
input: movement = [’U’, ’U’, ’I’, ’L’, ’D’, ’R’] output: bad input

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:40
What are the three parts to physical security standards for various types of army equipment and the risk level
Answers: 2
question
Computers and Technology, 22.06.2019 16:30
Technician a says that a dry sump system uses no oil storage sump under the engine. technician b says that a wet sump system uses no oil storage sump under the engine. who is correct?
Answers: 3
question
Computers and Technology, 22.06.2019 22:40
In this lab, you complete a python program that calculates an employee's annual bonus. input is an employee's first name, last name, salary, and numeric performance rating. if the rating is 1, 2, or 3, the bonus rate used is .25, .15, or .1 respectively. if the rating is 4 or higher, the rate is 0. the employee bonus is calculated by multiplying the bonus rate by the annual salary.
Answers: 1
question
Computers and Technology, 23.06.2019 11:00
Describe three characteristics of at-risk drivers. a. b. c. describe three characteristics of safe drivers. a. b. c. describe three driver errors that could cause a collision. a. b. c. how will this information affect you as a driver now and in the future? (2-3 sentences)
Answers: 2
You know the right answer?
A certain robot can perform only 4 types of movement. It can move either up or down or left or right...
Questions
question
Mathematics, 13.11.2020 22:10
question
Mathematics, 13.11.2020 22:10