Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
GPS Coordinate System (latitude, longitude, altitude)
📖 Scenario: You are programming a drone to record its GPS position. The drone uses three values: latitude, longitude, and altitude to know where it is in the sky.Latitude and longitude tell the drone where it is on the Earth's surface. Altitude tells how high it is above the ground.
🎯 Goal: You will create a program that stores a GPS coordinate with latitude, longitude, and altitude. Then you will set a limit for altitude, check if the drone is flying too high, and finally print a message with the drone's position and altitude status.
📋 What You'll Learn
Create a dictionary called gps_coordinate with keys 'latitude', 'longitude', and 'altitude' and exact values 37.7749, -122.4194, and 120 respectively.
Create a variable called max_altitude and set it to 100.
Create a variable called altitude_status that is 'Too High' if the altitude is greater than max_altitude, otherwise 'Safe'.
Print a message showing the latitude, longitude, altitude, and altitude status in this exact format: "Drone position: (37.7749, -122.4194), Altitude: 120m - Status: Too High".
💡 Why This Matters
🌍 Real World
Drones use GPS coordinates to navigate and maintain safe flying heights. This program helps monitor if the drone is flying within safe altitude limits.
💼 Career
Understanding GPS data and conditional checks is important for drone programming, robotics, and any job involving location tracking and safety monitoring.
Progress0 / 4 steps
1
Create the GPS coordinate dictionary
Create a dictionary called gps_coordinate with these exact entries: 'latitude': 37.7749, 'longitude': -122.4194, and 'altitude': 120.
Drone Programming
Hint
Use curly braces {} to create a dictionary. Put keys and values separated by colons.
2
Set the maximum allowed altitude
Create a variable called max_altitude and set it to 100.
Drone Programming
Hint
Just write the variable name, an equals sign, and the number 100.
3
Check if altitude is too high
Create a variable called altitude_status that is 'Too High' if gps_coordinate['altitude'] is greater than max_altitude, otherwise 'Safe'. Use a simple if-else statement.
Drone Programming
Hint
Use if to check the altitude, then assign the correct string to altitude_status.
4
Print the drone position and altitude status
Write a print statement that shows the message: "Drone position: (37.7749, -122.4194), Altitude: 120m - Status: Too High" using the values from gps_coordinate and altitude_status. Use an f-string.
Drone Programming
Hint
Use print(f"...") and insert the dictionary values and altitude_status inside curly braces.
Practice
(1/5)
1. What does the altitude value represent in a drone's GPS coordinate system?
easy
A. The height of the drone above sea level
B. The distance east or west from the Prime Meridian
C. The distance north or south from the Equator
D. The speed of the drone in meters per second
Solution
Step 1: Understand GPS coordinate components
GPS coordinates include latitude, longitude, and altitude. Latitude and longitude locate position on Earth, altitude shows height.
Step 2: Identify altitude meaning
Altitude measures how high the drone is above sea level, not horizontal position or speed.
Final Answer:
The height of the drone above sea level -> Option A
Quick Check:
Altitude = height above sea level [OK]
Hint: Altitude means height, not horizontal position [OK]
Common Mistakes:
Confusing altitude with latitude or longitude
Thinking altitude measures speed
Mixing altitude with horizontal distance
2. Which of the following is the correct way to represent a GPS coordinate in code for a drone?
easy
A. gps = {latitude: altitude, longitude: altitude}
B. gps = [altitude, longitude, latitude]
C. gps = (latitude, longitude, altitude)
D. gps = latitude + longitude + altitude
Solution
Step 1: Recognize GPS coordinate format
GPS coordinates are usually stored as a tuple or list with latitude, longitude, and altitude in order.
Step 2: Check each option
gps = (latitude, longitude, altitude) uses a tuple with correct order. gps = [altitude, longitude, latitude] swaps order. gps = {latitude: altitude, longitude: altitude} uses a dictionary incorrectly. gps = latitude + longitude + altitude adds numbers incorrectly.
Final Answer:
gps = (latitude, longitude, altitude) -> Option C
Quick Check:
Tuple with lat, long, alt in order [OK]
Hint: Use (latitude, longitude, altitude) tuple for GPS [OK]
A. gps tuple is assigned before variables, so it holds old values
B. Latitude and longitude values are swapped
C. Altitude should be a string, not a number
D. print(gps) causes a syntax error
Solution
Step 1: Analyze variable assignment order
gps is assigned before latitude, longitude, altitude variables get values, so gps holds undefined or old values.
Step 2: Understand variable update effect
Changing latitude, longitude, altitude after gps assignment does not update gps tuple automatically.
Final Answer:
gps tuple is assigned before variables, so it holds old values -> Option A
Quick Check:
Assign variables before tuple [OK]
Hint: Assign variables before creating gps tuple [OK]
Common Mistakes:
Assigning tuple before variables
Swapping latitude and longitude values
Thinking print causes error
5. You want to write a function is_above_altitude(gps, threshold) that returns True if the drone's altitude is above a given threshold. Which code correctly implements this?
hard
A. def is_above_altitude(gps, threshold):
return gps[2] < threshold
B. def is_above_altitude(gps, threshold):
return gps[0] > threshold
C. def is_above_altitude(gps, threshold):
return gps[1] > threshold
D. def is_above_altitude(gps, threshold):
return gps[2] > threshold
Solution
Step 1: Identify altitude index in GPS tuple
GPS tuple is (latitude, longitude, altitude), so altitude is at index 2.
Step 2: Compare altitude with threshold
Return True if gps[2] (altitude) is greater than threshold.
Final Answer:
def is_above_altitude(gps, threshold):
return gps[2] > threshold -> Option D
Quick Check:
Check altitude at index 2 > threshold [OK]
Hint: Altitude is gps[2], compare with threshold [OK]