Bird
Raised Fist0
Drone Programmingprogramming~20 mins

goto() command for navigation in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Master of goto() Navigation
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of goto() with simple coordinates
What will be the output of this drone navigation code snippet?
Drone Programming
drone.goto(10, 20, 5)
print(drone.position())
A(10, 20)
B(0, 0, 0)
C(10, 20, 5)
DError: Invalid coordinates
Attempts:
2 left
💡 Hint
The goto() command moves the drone to the specified x, y, z coordinates.
Predict Output
intermediate
2:00remaining
Effect of sequential goto() commands
What will be the drone's final position after running this code?
Drone Programming
drone.goto(5, 5, 5)
drone.goto(10, 0, 0)
print(drone.position())
A(5, 5, 5)
B(0, 0, 0)
C(15, 5, 5)
D(10, 0, 0)
Attempts:
2 left
💡 Hint
Each goto() command moves the drone to a new absolute position.
🔧 Debug
advanced
2:00remaining
Identify the error in goto() usage
This code is intended to move the drone to (10, 10, 10). What error will it cause?
Drone Programming
drone.goto(10, 10)
print(drone.position())
ATypeError: missing 1 required positional argument 'z'
BSyntaxError: invalid syntax
CValueError: coordinates must be positive
DNo error, outputs (10, 10, 0)
Attempts:
2 left
💡 Hint
The goto() command requires three coordinates: x, y, and z.
🧠 Conceptual
advanced
2:00remaining
Understanding relative vs absolute goto()
Which statement correctly describes the difference between absolute and relative goto() commands?
AAbsolute goto() moves the drone by offsets; relative goto() moves it to exact coordinates.
BAbsolute goto() moves the drone to exact coordinates; relative goto() moves it by offsets from current position.
CBoth absolute and relative goto() move the drone to exact coordinates but use different units.
DRelative goto() moves the drone to the origin; absolute goto() moves it randomly.
Attempts:
2 left
💡 Hint
Think about whether the drone moves to a fixed point or moves relative to where it is now.
Predict Output
expert
3:00remaining
Output after complex navigation sequence
What is the final position printed by this code?
Drone Programming
drone.goto(0, 0, 0)
drone.goto(5, 5, 5)
drone.goto(5, 10, 5)
drone.goto(10, 10, 10)
print(drone.position())
A(10, 10, 10)
B(5, 10, 5)
C(0, 0, 0)
D(15, 25, 20)
Attempts:
2 left
💡 Hint
Each goto() sets the drone's position absolutely, not cumulatively.

Practice

(1/5)
1. What does the goto(x, y, z, speed) command do in drone programming?
easy
A. Moves the drone to the specified coordinates at the given speed.
B. Starts the drone's camera recording.
C. Lands the drone immediately.
D. Turns the drone around 360 degrees.

Solution

  1. Step 1: Understand the purpose of goto()

    The goto() command is designed to move the drone to a specific location using coordinates.
  2. Step 2: Analyze the parameters

    The parameters x, y, z represent the position in space, and speed controls how fast the drone moves there.
  3. Final Answer:

    Moves the drone to the specified coordinates at the given speed. -> Option A
  4. Quick Check:

    goto() moves drone = A [OK]
Hint: Remember: goto() moves drone to coordinates fast or slow [OK]
Common Mistakes:
  • Confusing goto() with camera or landing commands
  • Ignoring the speed parameter
  • Thinking goto() rotates the drone
2. Which of the following is the correct syntax to move a drone to position (10, 20, 5) at speed 3 using goto()?
easy
A. goto(10, 20, 3, 5)
B. goto(10, 20, 5, 3)
C. goto(3, 10, 20, 5)
D. goto(5, 3, 10, 20)

Solution

  1. Step 1: Identify parameter order

    The goto() command takes parameters in order: x, y, z, speed.
  2. Step 2: Match values to parameters

    Given position (10, 20, 5) and speed 3, the correct call is goto(10, 20, 5, 3).
  3. Final Answer:

    goto(10, 20, 5, 3) -> Option B
  4. Quick Check:

    Order is x,y,z,speed = C [OK]
Hint: Remember parameter order: x, y, z, then speed [OK]
Common Mistakes:
  • Mixing up speed with coordinate values
  • Changing parameter order
  • Using wrong numbers for coordinates
3. What will be the drone's final position after running this code?
goto(5, 5, 10, 2)
goto(10, 10, 5, 4)
medium
A. (0, 0, 0)
B. (5, 5, 10)
C. (15, 15, 15)
D. (10, 10, 5)

Solution

  1. Step 1: Execute first goto()

    The drone moves to coordinates (5, 5, 10) at speed 2.
  2. Step 2: Execute second goto()

    The drone then moves to (10, 10, 5) at speed 4, which is the final position.
  3. Final Answer:

    (10, 10, 5) -> Option D
  4. Quick Check:

    Last goto() position = A [OK]
Hint: Last goto() sets final position, earlier ones are overwritten [OK]
Common Mistakes:
  • Adding coordinates instead of replacing
  • Ignoring the second goto()
  • Confusing speed with position
4. Identify the error in this code snippet:
goto(10, 20, speed=5, 3)
medium
A. Speed parameter is given before z coordinate.
B. No error; code is correct.
C. Using named argument for speed but position parameters are positional.
D. Missing one coordinate parameter.

Solution

  1. Step 1: Check parameter usage

    The code mixes positional and named arguments incorrectly by placing speed=5 before the last positional argument.
  2. Step 2: Understand Python argument rules

    Positional arguments must come before named arguments; here, 3 is positional after a named argument, causing a syntax error.
  3. Final Answer:

    Using named argument for speed but position parameters are positional. -> Option C
  4. Quick Check:

    Named args after positional = D [OK]
Hint: Named arguments must come after all positional ones [OK]
Common Mistakes:
  • Placing named arguments before positional
  • Assuming order doesn't matter
  • Missing commas between parameters
5. You want the drone to inspect three points in order: (0,0,5), (10,0,5), and (10,10,5), each at speed 2. Which code correctly uses goto() to do this?
hard
A. goto(0, 0, 5, 2) goto(10, 0, 5, 2) goto(10, 10, 5, 2)
B. goto([0,0,5], 2) goto([10,0,5], 2) goto([10,10,5], 2)
C. goto(0, 0, 5) goto(10, 0, 5) goto(10, 10, 5)
D. goto(0, 0, 5, 2, 3) goto(10, 0, 5, 2, 3) goto(10, 10, 5, 2, 3)

Solution

  1. Step 1: Check parameter correctness

    Each goto() call must have four parameters: x, y, z, and speed.
  2. Step 2: Validate each option

    goto(0, 0, 5, 2) goto(10, 0, 5, 2) goto(10, 10, 5, 2) correctly uses four parameters per call. goto([0,0,5], 2) goto([10,0,5], 2) goto([10,10,5], 2) uses lists instead of separate coordinates. goto(0, 0, 5) goto(10, 0, 5) goto(10, 10, 5) misses speed. goto(0, 0, 5, 2, 3) goto(10, 0, 5, 2, 3) goto(10, 10, 5, 2, 3) has an extra parameter.
  3. Final Answer:

    goto(0, 0, 5, 2) goto(10, 0, 5, 2) goto(10, 10, 5, 2) -> Option A
  4. Quick Check:

    Correct parameters and order = B [OK]
Hint: Use four parameters: x, y, z, speed for each goto() [OK]
Common Mistakes:
  • Passing coordinates as a list instead of separate values
  • Omitting speed parameter
  • Adding extra parameters