0
0
Drone Programmingprogramming~20 mins

Altitude limits configuration in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Altitude Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this altitude check code?
Given the drone altitude limits set between 10 and 120 meters, what will the program print when the altitude is 130?
Drone Programming
min_altitude = 10
max_altitude = 120
current_altitude = 130
if current_altitude < min_altitude:
    print("Below minimum altitude")
elif current_altitude > max_altitude:
    print("Above maximum altitude")
else:
    print("Altitude within limits")
AAbove maximum altitude
BBelow minimum altitude
CAltitude within limits
DNo output
Attempts:
2 left
💡 Hint
Check the condition that compares current altitude with max altitude.
Predict Output
intermediate
2:00remaining
What is the value of 'safe_to_fly' after running this code?
The drone must fly only if altitude is between 20 and 100 meters inclusive. What is the value of 'safe_to_fly' if altitude is 20?
Drone Programming
min_altitude = 20
max_altitude = 100
altitude = 20
safe_to_fly = min_altitude <= altitude <= max_altitude
AFalse
BTrue
CNone
DError
Attempts:
2 left
💡 Hint
Check if the altitude is within the inclusive range.
🔧 Debug
advanced
2:00remaining
What error does this altitude validation code raise?
Identify the error when running this code that checks if altitude is within limits.
Drone Programming
min_altitude = 15
max_altitude = 90
altitude = 50
if altitude > min_altitude and altitude < max_altitude:
    print("Altitude OK")
else:
    print("Altitude out of range")
ANameError: name 'altitude' is not defined
BTypeError: unsupported operand type(s) for >
CSyntaxError: expected ':' after else
DNo error, prints 'Altitude OK'
Attempts:
2 left
💡 Hint
Look carefully at the else statement syntax.
Predict Output
advanced
2:00remaining
How many altitude values are stored after this configuration?
The code stores altitude limits in a dictionary for different zones. How many zones are configured?
Drone Programming
altitude_limits = {
    'zone1': (10, 50),
    'zone2': (20, 80),
    'zone3': (15, 60),
    'zone4': (5, 100)
}
print(len(altitude_limits))
AError
B3
C5
D4
Attempts:
2 left
💡 Hint
Count the number of keys in the dictionary.
🧠 Conceptual
expert
3:00remaining
Which option correctly describes the effect of this altitude limit code snippet?
Consider this code snippet that sets altitude limits and checks a drone's altitude: min_altitude = 30 max_altitude = 90 altitude = 90 if altitude >= min_altitude and altitude <= max_altitude: status = "Safe" else: status = "Unsafe" What is the value of 'status' and why?
A"Safe" because altitude equals the maximum limit and the condition includes equality
B"Safe" because altitude is greater than min_altitude only
C"Unsafe" because altitude equals max_altitude which is not allowed
D"Unsafe" because altitude must be strictly less than max_altitude
Attempts:
2 left
💡 Hint
Check the comparison operators used in the condition.