1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
snow_tiger [21]
4 years ago
8

A certain robot can perform only 4 types of movement. It can move either up or down or left or right. These movements are repres

ented 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".
Engineering
1 answer:
Olegator [25]4 years ago
8 0

Answer:

def theRoundTrip(movement):

   x=0

   y=0

   for i in movement:

       if i not in ["U","L","D","R"]:

           print("bad input")

           return

       if i=="U":

           y+=1

       if i=="L":

           x-=1

       if i=="D":

           y-=1

       if i=="R":

           x+=1

   return x==0 and y==0

You might be interested in
Write a C++ program to display yearly calendar. You need to use the array defined below in your program. // the first number is
ddd [48]

Answer:

//Annual calendar

#include <iostream>

#include <string>

#include <iomanip>

void month(int numDays, int day)

{

int i;

string weekDays[] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};

// Header print

      cout << "\n----------------------\n";

      for(i=0; i<7; i++)

{

cout << left << setw(1) << weekDays[i];

cout << left << setw(1) << "|";

}

cout << left << setw(1) << "|";

      cout << "\n----------------------\n";

      int firstDay = day-1;

      //Space print

      for(int i=1; i< firstDay; i++)

          cout << left << setw(1) << "|" << setw(2) << " ";

      int cellCnt = 0;

      // Iteration of days

      for(int i=1; i<=numDays; i++)

      {

          //Output days

          cout << left << setw(1) << "|" << setw(2) << i;

          cellCnt += 1;

          // New line

          if ((i + firstDay-1) % 7 == 0)

          {

              cout << left << setw(1) << "|";

              cout << "\n----------------------\n";

              cellCnt = 0;

          }

      }

      // Empty cell print

      if (cellCnt != 0)

      {

          // For printing spaces

          for(int i=1; i<7-cellCnt+2; i++)

              cout << left << setw(1) << "|" << setw(2) << " ";

          cout << "\n----------------------\n";

      }

}

int main()

{

int i, day=1;

int yearly[12][2] = {{1,31},{2,28},{3,31},{4,30},{5,31},{6,30},{7,31},{8,31},{9,30},{10,31},{11,30},{12,31}};

string months[] = {"January",

"February",

"March",

"April",

"May",

"June",

"July",

"August",

"September",

"October",

"November",

"December"};

for(i=0; i<12; i++)

{

//Monthly printing

cout << "\n Month: " << months[i] << "\n";

month(yearly[i][1], day);

if(day==7)

{

day = 1;

}

else

{

day = day + 1;

}

cout << "\n";

}

return 0;

}

//end

3 0
4 years ago
List and describe three classifications of burns to the body.
DiKsa [7]

AnswerWhat Are the Classifications of Burns? Burns are classified as first-, second-, or third-degree, depending on how deep and severe they penetrate the skin's surface. First-degree burns affect only the epidermis, or outer layer of skin. The burn site is red, painful, dry, and with no blisters.

Explanation:

8 0
3 years ago
Read 2 more answers
A crankcase heater is often used to prevent refrigerant from mixing with compressor oil during periods of:
stira [4]

Answer:

Low ambient temperature

Explanation:

Hope this helps. If it did, please mark as brianliest so other people see it. Thanks! - Kai

5 0
3 years ago
Read 2 more answers
Why does an object under forced convection reach a steady-state faster than an object subjected to free-convection?
bonufazy [111]

Answer:

Free convection:

   When heat transfer occurs due to density difference between fluid then this type of heat transfer is know as free convection.The velocity of fluid is zero or we can say that fluid is not moving.

Force convection:

   When heat transfer occurs due to some external force then this type of heat transfer is know as force convection.The velocity of fluid is not zero or we can say that fluid is moving in force convection.

Heat transfer coefficient of force convection is high as compare to the natural convection.That is why heat force convection reach a steady-state faster than an object subjected to free-convection.

We know that convective heat transfer given as

 q = h  A ΔT

h=Heat transfer coefficient

A= Surface area

ΔT = Temperature difference

5 0
4 years ago
What are the four categories of engineering materials used in manufacturing?
alexgriva [62]

Answer:

metals, composite, ceramics and polymers.

Explanation:

The four categories of engineering materials used in manufacturing are metals, composite, ceramics and polymers.

i) Metals: Metals are solids made up of atoms held by matrix of electrons. They are good conductors of heat and electricity, ductile and strong.

ii) Composite: This is a combination of two or more materials. They have high strength to weight ratio, stiff, low conductivity. E.g are wood, concrete.

iii) Ceramics: They are inorganic, non-metallic crystalline compounds with high hardness and strength as well as poor conductors of electricity and heat.

iv) Polymers: They  have low weight and are poor conductors of electricity and heat

8 0
3 years ago
Other questions:
  • A large spherical tank contains gas at a pressure of 400 psi. The tank is constructed of high-strength steel having a yield stre
    15·1 answer
  • Occurs between a tire on a vehicle and the roadway when a wall of water separates the tire from
    15·1 answer
  • technician A says that in any circuit, electrical current takes the path of least resistance. technician B says that while this
    13·1 answer
  • The basic concept of feedback control is that an error must exist before some corrective action can be made?
    12·1 answer
  • You are given that kc = 10-1 kg eq-1 min-1, ku = 10-3 kg2 eq-2 min-1 and [A]0 = 10 eq kg-1, where kc is the rate constant for a
    15·1 answer
  • Consider a Carnot refrigeration cycle executed in a closed system in the saturated liquid-vapor mixture region using 0.96 kg of
    11·1 answer
  • All of the following are categories for clutch covers except
    11·1 answer
  • Module 42 Review and Assessment
    7·1 answer
  • Engine horsepower decreases ________% for every___________feet above sea level.
    9·1 answer
  • Ignition for heavy fuel oil?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!