Complete the code to define a drone's basic property.
class Drone: def __init__(self, [1]): self.name = name
The constructor needs a parameter called name to set the drone's name.
Complete the code to make the drone fly at a given altitude.
def fly(self, [1]): self.altitude = altitude print(f"Flying at {altitude} meters")
The method fly needs an altitude parameter to set how high the drone flies.
Fix the error in the method that makes the drone land.
def land(self): self.altitude = [1] print("Drone has landed")
Setting altitude to 0 means the drone is on the ground, so it has landed.
Fill both blanks to create a dictionary of drone names and their altitudes above 10 meters.
drones = {'Alpha': 5, 'Bravo': 15, 'Charlie': 20}
high_flyers = { [1] : drones[[2]] for [1] in drones if drones[[1]] > 10 }We use name as the key variable to loop through the dictionary keys and filter by altitude.
Fill all three blanks to create a dictionary of drone names in uppercase with altitudes above 10 meters.
drones = {'Alpha': 5, 'Bravo': 15, 'Charlie': 20}
high_flyers = { [1] : [2] for [3] in drones if drones[[3]] > 10 }The key is the drone name in uppercase, the value is the altitude, and the loop variable is the drone name.
