📖 Scenario: You are programming a drone to prepare it for flight. Before the drone can take off, it needs to be armed (ready to start motors) and then take off to a certain height.
🎯 Goal: Build a simple program that arms the drone and commands it to take off to a height of 10 meters.
📋 What You'll Learn
Create a variable called drone_status to store the current status of the drone.
Create a variable called takeoff_height and set it to 10.
Write code to arm the drone by setting drone_status to 'armed'.
Write code to command the drone to take off to the height stored in takeoff_height.
Print the final status message showing the drone is armed and taking off to the correct height.
💡 Why This Matters
🌍 Real World
Drones need to be armed before flight to ensure safety. Programming the takeoff command helps automate flying to a set height.
💼 Career
Understanding how to control drone states and commands is important for drone operators, robotics programmers, and developers working with autonomous flying devices.
Progress0 / 4 steps
1
Set up the drone status variable
Create a variable called drone_status and set it to the string 'disarmed' to show the drone is not ready yet.
Drone Programming
Hint
Think of drone_status as a label that tells if the drone is ready or not.
2
Set the takeoff height
Create a variable called takeoff_height and set it to the number 10 to represent 10 meters.
Drone Programming
Hint
This number tells the drone how high to fly.
3
Arm the drone and command takeoff
Set the variable drone_status to the string 'armed' to arm the drone. Then create a variable called takeoff_command and set it to the string f'Taking off to {takeoff_height} meters' to command the drone to take off.
Drone Programming
Hint
Use an f-string to include the height number inside the message.
4
Print the drone status and takeoff command
Print the message f'Drone status: {drone_status}' and then print the variable takeoff_command to show the drone is armed and taking off.
Drone Programming
Hint
Use two print statements, one for status and one for the command.
Practice
(1/5)
1. What is the first step to safely make a drone fly using commands?
easy
A. Arm the drone motors
B. Takeoff to a height
C. Land the drone
D. Turn off the drone
Solution
Step 1: Understand drone startup sequence
Before flying, the drone motors must be started to prepare for flight.
Step 2: Identify the correct first command
The 'arm' command starts the motors, which is necessary before takeoff.
Final Answer:
Arm the drone motors -> Option A
Quick Check:
First step = Arm motors [OK]
Hint: Always arm before takeoff to start motors safely [OK]
Common Mistakes:
Trying to takeoff before arming
Skipping arming step
Confusing landing with arming
2. Which of the following is the correct syntax to arm a drone in Python?
easy
A. arm.drone()
B. drone.arm()
C. drone.takeoff()
D. arm()
Solution
Step 1: Identify the object and method
To arm the drone, the method 'arm()' is called on the drone object.
Step 2: Check syntax correctness
'drone.arm()' correctly calls the arm method on the drone instance.
Final Answer:
drone.arm() -> Option B
Quick Check:
Correct method call = drone.arm() [OK]
Hint: Call arm() on drone object to start motors [OK]