📖 Scenario: You are programming a simple drone control system. To make the drone hover steadily in the air, the thrust force generated by the drone's motors must exactly balance the drone's weight. This means the thrust should be equal to the weight.We will write a small program to check if the drone is hovering by comparing thrust and weight values.
🎯 Goal: Build a program that stores the drone's weight and thrust values, then checks if the drone is hovering by comparing these values. Finally, print a message indicating whether the drone is hovering or not.
📋 What You'll Learn
Create variables for drone weight and thrust with exact values
Create a variable to store the hover tolerance threshold
Use an if-else statement to check if thrust equals weight within the threshold
Print 'Hovering' if thrust equals weight within threshold, else print 'Not hovering'
💡 Why This Matters
🌍 Real World
Drones must maintain stable hover to perform tasks like photography or delivery safely.
💼 Career
Understanding how to compare forces and control conditions is important for drone software developers and robotics engineers.
Progress0 / 4 steps
1
Set up drone weight and thrust variables
Create two variables called weight and thrust with the exact values 10.0 and 9.8 respectively.
Drone Programming
Hint
Use simple assignment statements like weight = 10.0.
2
Add hover tolerance threshold
Create a variable called tolerance and set it to 0.2 to allow a small difference between thrust and weight.
Drone Programming
Hint
This variable helps us decide if thrust is close enough to weight to hover.
3
Check if drone is hovering
Write an if statement that checks if the absolute difference between thrust and weight is less than or equal to tolerance. Use abs(thrust - weight) <= tolerance as the condition.
Drone Programming
Hint
Use the abs() function to get the positive difference.
4
Print hover status
Write a print statement that prints 'Hovering' if hovering is True, otherwise print 'Not hovering'.
Drone Programming
Hint
Use an if-else to print the correct message based on the hovering variable.
Practice
(1/5)
1. What does the hover condition thrust == weight mean for a drone?
easy
A. The drone's battery is fully charged.
B. The drone will start moving upward quickly.
C. The drone will fall down immediately.
D. The drone stays steady in the air without moving up or down.
Solution
Step 1: Understand thrust and weight
Thrust is the upward force from the drone's propellers, and weight is the downward force due to gravity.
Step 2: Analyze the equality condition
When thrust equals weight, the forces balance, so the drone neither rises nor falls.
Final Answer:
The drone stays steady in the air without moving up or down. -> Option D
Quick Check:
Hover condition means thrust = weight [OK]
Hint: Hover means forces balance: thrust equals weight [OK]
Common Mistakes:
Thinking thrust > weight means hovering
Confusing thrust with battery power
Assuming thrust < weight means hovering
2. Which of the following is the correct way to check if thrust equals weight in drone programming?
easy
A. if thrust == weight:
B. if thrust != weight:
C. if thrust = weight:
D. if thrust => weight:
Solution
Step 1: Identify the comparison operator
In programming, == checks if two values are equal, while = assigns a value.
Step 2: Choose the correct syntax
To check equality, use if thrust == weight: which compares thrust and weight.
Final Answer:
if thrust == weight: -> Option A
Quick Check:
Use '==' for equality check [OK]
Hint: Use '==' to compare values, '=' is for assignment [OK]