Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a waypoint with latitude.
Drone Programming
waypoint = {'latitude': [1], 'longitude': -122.084} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the number, making it a string instead of a number.
✗ Incorrect
The latitude value must be a number, not a string or variable name.
2fill in blank
mediumComplete the code to add a waypoint to the mission list.
Drone Programming
mission = []
mission.append([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Appending a variable name that is not defined.
✗ Incorrect
You need to append a dictionary representing the waypoint, not a variable name.
3fill in blank
hardFix the error in the code to loop through waypoints correctly.
Drone Programming
for [1] in mission: print(f"Flying to {waypoint['latitude']}, {waypoint['longitude']}")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mission' as loop variable, which is the list, not an item.
✗ Incorrect
The loop variable should be 'waypoint' to match the print statement.
4fill in blank
hardFill both blanks to check if the drone reached the waypoint.
Drone Programming
if current_location['latitude'] [1] waypoint['latitude'] and current_location['longitude'] [2] waypoint['longitude']: print('Waypoint reached')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using greater than or less than operators which do not confirm exact location.
✗ Incorrect
We check if both latitude and longitude match exactly to confirm reaching the waypoint.
5fill in blank
hardFill both blanks to create a dictionary comprehension for waypoints above altitude 100.
Drone Programming
high_altitude_waypoints = {wp['name']: wp['altitude'] for wp in waypoints if wp['altitude'] [1] [2] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '==' which do not select waypoints above 100.
✗ Incorrect
The comprehension filters waypoints with altitude greater than 100.