Bird
Raised Fist0
Drone Programmingprogramming~20 mins

Delivery drone concept in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Delivery Drone Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
1:30remaining
Calculate remaining battery after delivery
A delivery drone starts with 100% battery. It uses 15% battery to fly to the destination and 10% to return. What is the remaining battery percentage after the round trip?
Drone Programming
battery = 100
used_to_destination = 15
used_to_return = 10
remaining_battery = battery - used_to_destination - used_to_return
print(remaining_battery)
A65
B75
C85
D90
Attempts:
2 left
💡 Hint
Subtract the battery used for both legs from the total battery.
🧠 Conceptual
intermediate
1:30remaining
Identify the drone's delivery status
The drone has a variable 'package_delivered' that is True if the package is delivered, False otherwise. Which code snippet correctly prints 'Delivered' when the package is delivered and 'In transit' otherwise?
A
if package_delivered:
    print('Delivered')
else:
    print('In transit')
B
if package_delivered == False:
    print('Delivered')
else:
    print('In transit')
C
if package_delivered = True:
    print('Delivered')
else:
    print('In transit')
D
)'tisnart nI'(tnirp    
:esle
)'derevileD'(tnirp    
:dereviled_egakcap fi
Attempts:
2 left
💡 Hint
Check the condition and indentation carefully.
🔧 Debug
advanced
2:00remaining
Fix the drone's flight path calculation error
The drone's flight path distance is calculated by adding the distances to destination and back. The code below has a bug. What error does it raise?
Drone Programming
distance_to_destination = 12.5
distance_to_return = '12.5'
total_distance = distance_to_destination + distance_to_return
print(total_distance)
ASyntaxError: invalid syntax
BNameError: name 'distance_to_return' is not defined
CTypeError: unsupported operand type(s) for +: 'float' and 'str'
DValueError: could not convert string to float
Attempts:
2 left
💡 Hint
Check the types of variables being added.
📝 Syntax
advanced
1:30remaining
Identify the syntax error in drone command function
Which option contains a syntax error in defining a function to start the drone?
A
def start_drone():
    print('Drone started')  # correct
B
def start_drone():
    print('Drone started')
C
)'detrats enorD'(tnirp    
:)(enord_trats fed
D
def start_drone:
    print('Drone started')
Attempts:
2 left
💡 Hint
Check the function definition syntax.
🚀 Application
expert
2:30remaining
Calculate total delivery time with variable speeds
A drone flies to a destination 20 km away at 40 km/h and returns at 30 km/h due to wind. What is the total flight time in hours?
A1.1666666666666667
B0.95
C0.75
D1.0
Attempts:
2 left
💡 Hint
Use time = distance / speed for each leg and add them.

Practice

(1/5)
1. What is the main purpose of a delivery drone in programming terms?
easy
A. To carry packages from one place to another automatically
B. To play music while flying
C. To take photos of landscapes
D. To clean the air by flying

Solution

  1. Step 1: Understand the drone's role

    A delivery drone is designed to transport packages safely and efficiently.
  2. Step 2: Match the purpose to options

    Only To carry packages from one place to another automatically describes carrying packages automatically, which fits delivery.
  3. Final Answer:

    To carry packages from one place to another automatically -> Option A
  4. Quick Check:

    Delivery drone = carry packages [OK]
Hint: Delivery drones move packages, not play or clean [OK]
Common Mistakes:
  • Confusing drone delivery with photography
  • Thinking drones clean air
  • Assuming drones play music
2. Which of the following is the correct way to set a package in a drone program?
easy
A. drone.package = 'Box'
B. drone->setPackage('Box')
C. setPackage(drone, 'Box')
D. drone.setPackage('Box')

Solution

  1. Step 1: Identify method call syntax

    In drone programming, methods are called on objects using dot notation like drone.setPackage('Box').
  2. Step 2: Check each option

    drone.setPackage('Box') uses correct method call syntax. drone.package = 'Box' assigns directly, which may not be allowed. setPackage(drone, 'Box') uses wrong function call style. drone->setPackage('Box') uses incorrect arrow syntax.
  3. Final Answer:

    drone.setPackage('Box') -> Option D
  4. Quick Check:

    Method call uses dot notation [OK]
Hint: Use dot notation for methods like setPackage() [OK]
Common Mistakes:
  • Using assignment instead of method call
  • Using arrow (->) instead of dot (.)
  • Calling method with wrong argument order
3. What will be the output of this drone program snippet?
drone.setPackage('Book')
drone.setDestination('Home')
print(drone.status())

Assuming status() returns a string showing package and destination.
medium
A. "Package: Book, Destination: None"
B. "Package: Book, Destination: Home"
C. "Package: None, Destination: Home"
D. "No package or destination set"

Solution

  1. Step 1: Analyze method calls

    The program sets the package to 'Book' and destination to 'Home'.
  2. Step 2: Understand status() output

    Status shows current package and destination, so it should reflect 'Book' and 'Home'.
  3. Final Answer:

    "Package: Book, Destination: Home" -> Option B
  4. Quick Check:

    Status shows set package and destination [OK]
Hint: status() shows current package and destination [OK]
Common Mistakes:
  • Assuming package or destination is None
  • Confusing output format
  • Ignoring previous set commands
4. Identify the error in this drone delivery code snippet:
drone.setPackage('Laptop')
drone.flyTo('Office')
drone.deliver()

Assuming flyTo moves drone but delivery requires destination set first.
medium
A. flyTo() should be flyToDestination()
B. Package not set before delivery
C. Missing destination set before flying
D. deliver() method does not exist

Solution

  1. Step 1: Check method order and requirements

    Delivery requires setting destination before flying. Here, destination is not set explicitly.
  2. Step 2: Identify missing step

    Code calls flyTo('Office') but does not set destination property, which delivery depends on.
  3. Final Answer:

    Missing destination set before flying -> Option C
  4. Quick Check:

    Destination must be set before flyTo and deliver [OK]
Hint: Always set destination before flying and delivering [OK]
Common Mistakes:
  • Skipping destination setup
  • Assuming flyTo sets destination automatically
  • Confusing method names
5. You want to program a drone to deliver multiple packages to different destinations in sequence. Which approach best fits this task?
hard
A. Use a loop to set each package and destination, then fly and deliver each time
B. Set all packages at once and fly to one destination only
C. Fly randomly and drop packages without setting destinations
D. Deliver packages without flying

Solution

  1. Step 1: Understand multi-package delivery needs

    Each package must be assigned a destination and delivered one by one.
  2. Step 2: Choose correct programming structure

    A loop allows repeating setPackage, setDestination, fly, and deliver steps for each package.
  3. Step 3: Evaluate other options

    Set all packages at once and fly to one destination only ignores multiple destinations. Fly randomly and drop packages without setting destinations is unsafe and random. Deliver packages without flying skips flying, which is needed.
  4. Final Answer:

    Use a loop to set each package and destination, then fly and deliver each time -> Option A
  5. Quick Check:

    Loop for sequential deliveries [OK]
Hint: Loop through packages and destinations for multiple deliveries [OK]
Common Mistakes:
  • Trying to deliver all packages at once
  • Ignoring destination assignment
  • Skipping flying step
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