0
0
Drone Programmingprogramming~30 mins

Delivery drone concept in Drone Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Delivery drone concept
📖 Scenario: You are programming a delivery drone that carries packages to different locations in a city. The drone needs to know the packages it carries, the maximum weight it can carry, and then calculate the total weight of the packages to check if it is within the limit.
🎯 Goal: Build a simple program that stores package weights, sets a maximum weight limit, calculates the total weight of packages, and prints whether the drone can carry all packages safely.
📋 What You'll Learn
Create a dictionary with package names and their weights
Create a variable for the drone's maximum weight capacity
Calculate the total weight of all packages using a loop
Print a message showing the total weight and if it is within the limit
💡 Why This Matters
🌍 Real World
Delivery drones need to manage their load carefully to avoid accidents and ensure safe delivery.
💼 Career
Understanding how to manage data and conditions is important for programming drones and other automated delivery systems.
Progress0 / 4 steps
1
Create the package weights dictionary
Create a dictionary called packages with these exact entries: 'PackageA': 2.5, 'PackageB': 1.0, 'PackageC': 3.0
Drone Programming
Need a hint?

Use curly braces to create a dictionary with keys as package names and values as weights.

2
Set the drone's maximum weight capacity
Create a variable called max_weight and set it to 7.0 to represent the drone's maximum weight capacity in kilograms.
Drone Programming
Need a hint?

Just assign the number 7.0 to the variable max_weight.

3
Calculate the total weight of packages
Create a variable called total_weight and set it to 0. Then use a for loop with variables package and weight to iterate over packages.items(). Inside the loop, add weight to total_weight.
Drone Programming
Need a hint?

Start with total_weight = 0. Then add each package's weight to total_weight inside the loop.

4
Print the total weight and check capacity
Write a print statement that shows the total weight using an f-string: print(f"Total weight: {total_weight} kg"). Then write an if statement to check if total_weight is less than or equal to max_weight. If yes, print "Drone can carry all packages safely." else print "Drone cannot carry all packages safely."
Drone Programming
Need a hint?

Use an f-string to print total_weight. Then use an if-else to print the correct message based on the weight check.