0
0
Drone Programmingprogramming~10 mins

Barometer for altitude in Drone Programming - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to read the current pressure from the barometer sensor.

Drone Programming
pressure = barometer.[1]()
Drag options to blanks, or click blank then click option'
Aread_pressure
Bcalibrate
Cstart
Dget_altitude
Attempts:
3 left
💡 Hint
Common Mistakes
Using get_altitude() instead of read_pressure()
Calling start() which initializes but does not read data
2fill in blank
medium

Complete the code to convert pressure to altitude using the barometer's method.

Drone Programming
altitude = barometer.[1](pressure)
Drag options to blanks, or click blank then click option'
Acalculate_altitude
Bread_altitude
Cmeasure_altitude
Dget_altitude
Attempts:
3 left
💡 Hint
Common Mistakes
Using calculate_altitude() which might not exist
Using read_altitude() which is not standard
3fill in blank
hard

Fix the error in the code to initialize the barometer sensor correctly.

Drone Programming
barometer = BarometerSensor([1])
Drag options to blanks, or click blank then click option'
Aport1
Bsensor_port
Ci2c_bus
Dgpio_pin
Attempts:
3 left
💡 Hint
Common Mistakes
Using gpio_pin which is for digital pins
Using port1 or sensor_port which are not standard identifiers
4fill in blank
hard

Fill both blanks to create a set of altitudes for each sensor reading above 100 meters.

Drone Programming
altitudes = {reading[1]2 for reading in readings if reading [2] 100}
Drag options to blanks, or click blank then click option'
A**
B>
C<
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' instead of '**' for squaring
Using '<' instead of '>' in the condition
5fill in blank
hard

Fill all three blanks to create a dictionary mapping sensor IDs to altitudes above 50 meters.

Drone Programming
altitude_map = [1]: [2] for id, [3] in sensor_data.items() if [2] > 50}
Drag options to blanks, or click blank then click option'
Aid
Baltitude
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using data as the loop variable instead of altitude
Mixing up keys and values in the dictionary comprehension