Bird
Raised Fist0
Drone Programmingprogramming~20 mins

Simulating missions before flight in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Mission Simulation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
Output of mission simulation with waypoint delays
What is the output of this drone mission simulation code snippet?
Drone Programming
mission = ['takeoff', 'waypoint1', 'waypoint2', 'land']
results = []
for step in mission:
    if step == 'takeoff':
        results.append('Taking off')
    elif step.startswith('waypoint'):
        results.append(f'Reached {step}')
    elif step == 'land':
        results.append('Landing')
print(results)
A['Taking off', 'Reached waypoint1', 'Landing']
B['Taking off', 'waypoint1', 'waypoint2', 'Landing']
C['Taking off', 'Reached waypoint1', 'Reached waypoint2', 'Landing']
D['takeoff', 'Reached waypoint1', 'Reached waypoint2', 'land']
Attempts:
2 left
💡 Hint
Look at how each mission step is checked and what is appended to results.
🧠 Conceptual
intermediate
1:30remaining
Understanding simulation state updates
In a drone mission simulation, why is it important to update the drone's position state after each waypoint?
ATo avoid logging any mission data
BTo ensure the drone's battery level is reset after each waypoint
CTo speed up the simulation by skipping waypoints
DTo keep track of the drone's current location for accurate navigation and safety checks
Attempts:
2 left
💡 Hint
Think about what position information helps with during flight.
🔧 Debug
advanced
2:00remaining
Identify the error in mission simulation loop
What error will this mission simulation code produce when run?
Drone Programming
mission = ['takeoff', 'waypoint1', 'land']
for step in mission:
    if step == 'takeoff':
        print('Taking off')
    elif step.startswith('waypoint'):
        print(f'Reached {step}')
    elif step == 'land':
        print('Landing')
ASyntaxError due to incorrect assignment operator in if condition
BNameError because 'mission' is not defined
CTypeError because 'step' is not a string
DNo error, prints all steps correctly
Attempts:
2 left
💡 Hint
Check the if condition syntax carefully.
📝 Syntax
advanced
2:00remaining
Correct dictionary comprehension for mission status
Which option correctly creates a dictionary mapping each waypoint to its status 'pending' in a mission list?
Drone Programming
mission = ['takeoff', 'waypoint1', 'waypoint2', 'land']
A{wp: 'pending' for wp in mission if wp.startswith('waypoint')}
B{wp: 'pending' if wp.startswith('waypoint') for wp in mission}
C{wp: 'pending' for wp in mission if wp == 'waypoint'}
D{wp: 'pending' for wp in mission where wp.startswith('waypoint')}
Attempts:
2 left
💡 Hint
Remember the syntax for dictionary comprehensions with conditions.
🚀 Application
expert
2:30remaining
Calculate total mission duration from simulation data
Given this simulation log of mission steps with durations in seconds, what is the total mission time?
Drone Programming
simulation_log = [
  {'step': 'takeoff', 'duration': 5},
  {'step': 'waypoint1', 'duration': 10},
  {'step': 'waypoint2', 'duration': 15},
  {'step': 'land', 'duration': 7}
]
total_time = sum(entry['duration'] for entry in simulation_log)
print(total_time)
A35
B37
C40
D30
Attempts:
2 left
💡 Hint
Add all durations from each step in the log.

Practice

(1/5)
1. What is the main purpose of simulating drone missions before actual flight?
easy
A. To make the drone fly faster in real life
B. To avoid charging the drone's battery
C. To save battery power during the flight
D. To test the mission plan safely and avoid real accidents

Solution

  1. Step 1: Understand the role of simulation

    Simulation runs the mission in a virtual environment to check for errors without risk.
  2. Step 2: Identify the benefit of safe testing

    This helps avoid mistakes and accidents during the real flight.
  3. Final Answer:

    To test the mission plan safely and avoid real accidents -> Option D
  4. Quick Check:

    Simulation = Safe testing before flight [OK]
Hint: Simulation means safe practice before real flight [OK]
Common Mistakes:
  • Thinking simulation makes the drone faster
  • Confusing simulation with battery saving
  • Believing simulation replaces real flight
2. Which of the following is the correct way to start a mission simulation in drone programming code?
easy
A. simulateMission(missionPlan)
B. startSimulation(missionPlan)
C. runMissionSimulation(missionPlan)
D. beginFlightSimulation(missionPlan)

Solution

  1. Step 1: Recognize the standard function name

    The common function to start simulation is named runMissionSimulation in drone programming APIs.
  2. Step 2: Compare options

    Only runMissionSimulation(missionPlan) matches the typical function name used for mission simulation.
  3. Final Answer:

    runMissionSimulation(missionPlan) -> Option C
  4. Quick Check:

    Function to start simulation = runMissionSimulation [OK]
Hint: Look for 'run' + 'MissionSimulation' in function names [OK]
Common Mistakes:
  • Using incorrect function names like startSimulation
  • Confusing mission start with simulation start
  • Misspelling function names
3. Given this code snippet simulating a mission:
mission = ['takeoff', 'fly_forward', 'turn_left', 'land']
result = runMissionSimulation(mission)
print(result)

What is the expected output?
medium
A. 'Mission completed successfully'
B. ['takeoff', 'turn_left', 'fly_forward', 'land']
C. Error: runMissionSimulation not defined
D. ['takeoff', 'fly_forward', 'turn_left', 'land']

Solution

  1. Step 1: Understand what runMissionSimulation returns

    This function simulates the mission and returns a status message, not the mission list.
  2. Step 2: Check the printed result

    Since the mission runs without errors, it returns 'Mission completed successfully'.
  3. Final Answer:

    'Mission completed successfully' -> Option A
  4. Quick Check:

    Simulation output = success message [OK]
Hint: Simulation returns status, not the mission list [OK]
Common Mistakes:
  • Expecting the mission list as output
  • Confusing error messages with success
  • Assuming function prints steps automatically
4. You wrote this code to simulate a mission but get an error:
mission = ['takeoff', 'fly_forward', 'land']
result = runMissionSim(mission)
print(result)

What is the likely cause of the error?
medium
A. The function name runMissionSim is incorrect
B. The mission list is empty
C. The print statement is missing parentheses
D. The mission commands are invalid

Solution

  1. Step 1: Check function name spelling

    The correct function is runMissionSimulation, not runMissionSim.
  2. Step 2: Verify mission list and print syntax

    The mission list is not empty and print uses parentheses correctly.
  3. Final Answer:

    The function name runMissionSim is incorrect -> Option A
  4. Quick Check:

    Function name typo causes error [OK]
Hint: Check exact function names for typos [OK]
Common Mistakes:
  • Assuming mission list is empty
  • Forgetting print parentheses
  • Blaming mission commands without checking function
5. You want to simulate a mission that includes conditional turns based on sensor data. Which approach correctly simulates this before flight?
mission = [
  'takeoff',
  'fly_forward',
  {'if': 'sensor_left_clear', 'then': 'turn_left', 'else': 'turn_right'},
  'land'
]
result = runMissionSimulation(mission)
print(result)
hard
A. The simulation will run both turns regardless of condition
B. The simulation evaluates the condition and executes the correct turn
C. The simulation ignores the conditional and skips the turn
D. The simulation crashes due to unsupported conditional format

Solution

  1. Step 1: Understand conditional simulation support

    Modern mission simulators can evaluate simple conditionals in mission plans.
  2. Step 2: Analyze the mission structure

    The mission includes a conditional dict that the simulator uses to decide which turn to execute based on sensor data.
  3. Final Answer:

    The simulation evaluates the condition and executes the correct turn -> Option B
  4. Quick Check:

    Simulators handle conditionals by evaluating them [OK]
Hint: Simulators process conditionals to choose actions [OK]
Common Mistakes:
  • Assuming both turns run regardless
  • Thinking conditionals are ignored
  • Believing simulation crashes on conditionals
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard