📖 Scenario: You are working on an electric vehicle (EV) project that uses a sensor suite to detect obstacles and navigate safely. The sensor suite includes LiDAR, radar, and camera sensors. Each sensor has specific properties like range, resolution, and type.
🎯 Goal: Build a simple data structure to represent the sensor suite, configure a threshold for detection range, filter sensors that meet the threshold, and finalize the sensor list for the EV system.
📋 What You'll Learn
Create a dictionary named sensor_suite with three sensors: LiDAR, Radar, and Camera.
Each sensor entry must be a dictionary with keys: type, range_meters, and resolution.
Add a variable min_range to set the minimum detection range threshold.
Use a dictionary comprehension to create a new dictionary active_sensors with sensors having range_meters greater than or equal to min_range.
Add a final key status with value "active" to each sensor in active_sensors.
💡 Why This Matters
🌍 Real World
Electric vehicles use sensor suites like LiDAR, radar, and cameras to detect obstacles and navigate safely.
💼 Career
Understanding how to organize and filter sensor data is important for roles in automotive engineering, robotics, and autonomous systems.
Progress0 / 4 steps
1
Create the sensor suite dictionary
Create a dictionary called sensor_suite with these exact entries: 'LiDAR', 'Radar', and 'Camera'. Each sensor should be a dictionary with keys and values exactly as follows: type: 'distance', range_meters: 100 for LiDAR, 200 for Radar, 50 for Camera, and resolution: 'high' for LiDAR, 'medium' for Radar, 'low' for Camera.
EV Technology
Hint
Use a dictionary with keys as sensor names and values as dictionaries with the specified keys and values.
2
Set the minimum detection range threshold
Add a variable called min_range and set it to the integer value 100 to represent the minimum detection range in meters.
EV Technology
Hint
Just create a variable named min_range and assign it the value 100.
3
Filter sensors by minimum range
Use a dictionary comprehension to create a new dictionary called active_sensors that includes only sensors from sensor_suite where the range_meters value is greater than or equal to min_range.
EV Technology
Hint
Use a dictionary comprehension with for name, details in sensor_suite.items() and filter by details['range_meters'] >= min_range.
4
Add status to active sensors
Add a key 'status' with the value 'active' to each sensor dictionary inside active_sensors.
EV Technology
Hint
Use a for loop over active_sensors.values() and add the key 'status' with value 'active' to each sensor dictionary.
Practice
(1/5)
1. Which sensor in an electric vehicle's sensor suite is best at creating detailed 3D maps of the surroundings?
easy
A. LiDAR
B. Radar
C. Camera
D. Ultrasonic sensor
Solution
Step 1: Understand LiDAR's function
LiDAR uses laser light to measure distances and create detailed 3D maps of the environment.
Step 2: Compare with other sensors
Radar uses radio waves mainly for detecting objects and speed, cameras capture images but don't directly measure distance in 3D, and ultrasonic sensors are for close range detection.
Final Answer:
LiDAR -> Option A
Quick Check:
3D mapping = LiDAR [OK]
Hint: LiDAR uses lasers for 3D maps, unlike radar or cameras [OK]
Common Mistakes:
Confusing radar with LiDAR for detailed mapping
Thinking cameras provide 3D distance data directly
Assuming ultrasonic sensors cover long distances
2. Which of the following correctly lists the three main sensors in an electric vehicle's sensor suite?
easy
A. Camera, ultrasonic, GPS
B. Radar, GPS, camera
C. LiDAR, sonar, GPS
D. LiDAR, radar, camera
Solution
Step 1: Recall the main sensors used in EV sensor suites
The main sensors are LiDAR, radar, and cameras, which together provide a full view of the environment.
Step 2: Eliminate incorrect options
GPS is for location, sonar and ultrasonic are not the primary sensors in this suite.
Final Answer:
LiDAR, radar, camera -> Option D
Quick Check:
Main EV sensors = LiDAR, radar, camera [OK]
Hint: Remember the trio: LiDAR, radar, and camera [OK]
Common Mistakes:
Including GPS as a main sensor for environment sensing
Confusing sonar or ultrasonic with radar
Mixing unrelated sensors in the list
3. Consider this simplified sensor data processing code snippet for an EV sensor suite:
def detect_objects(lidar_data, radar_data, camera_data):
objects = set()
if lidar_data > 0:
objects.add('Obstacle')
if radar_data > 0:
objects.add('Moving object')
if camera_data == 'clear':
objects.add('No hazard')
return objects
result = detect_objects(5, 0, 'clear')
print(result)
What will be printed?
medium
A. {'Moving object', 'No hazard'}
B. {'Obstacle', 'No hazard'}
C. {'Obstacle', 'Moving object', 'No hazard'}
D. {'No hazard'}
Solution
Step 1: Analyze input values and conditions
Input values are lidar_data=5, radar_data=0, camera_data='clear'. Since lidar_data > 0, 'Obstacle' is added. radar_data is 0, so 'Moving object' is not added. camera_data is 'clear', so 'No hazard' is added.
Step 2: Determine the final set contents
The set contains 'Obstacle' and 'No hazard'.
Final Answer:
{'Obstacle', 'No hazard'} -> Option B
Quick Check:
Conditions met = Obstacle + No hazard [OK]
Hint: Check each if condition carefully with given inputs [OK]
Common Mistakes:
Assuming radar_data=0 adds 'Moving object'
Ignoring camera_data condition
Confusing set contents order
4. The following code is intended to detect if any sensor detects an obstacle. What is the error?
def check_obstacle(lidar, radar, camera):
if lidar or radar > 0:
return True
elif camera == 'obstacle':
return True
else:
return False
print(check_obstacle(0, 0, 'clear'))
medium
A. The print statement is missing parentheses.
B. The function should return strings, not booleans.
C. The condition 'lidar or radar > 0' is incorrect; it should check both separately.
D. The camera comparison should be 'camera == obstacle' without quotes.
Solution
Step 1: Analyze the condition 'lidar or radar > 0'
This condition is evaluated as 'lidar' or '(radar > 0)', which is incorrect because it does not check if lidar > 0.
Step 2: Correct the condition to check both sensors properly
It should be 'lidar > 0 or radar > 0' to correctly detect obstacles from either sensor.
Final Answer:
The condition 'lidar or radar > 0' is incorrect; it should check both separately. -> Option C
Quick Check:
Check each sensor comparison explicitly [OK]
Hint: Use parentheses and compare each sensor explicitly [OK]
Common Mistakes:
Using 'or' without comparing both variables
Misunderstanding operator precedence
Ignoring boolean vs numeric comparisons
5. An electric vehicle uses LiDAR, radar, and cameras together to detect obstacles. If the LiDAR fails in heavy rain, which sensor is most reliable to still detect moving objects and why?
hard
A. Radar, because radio waves penetrate rain better than light
B. Camera, because images are clearer in rain
C. LiDAR, because it uses lasers unaffected by weather
D. null, all sensors fail in rain
Solution
Step 1: Understand sensor performance in rain
LiDAR uses laser light which can be scattered by rain, reducing effectiveness. Cameras can be blurred by water droplets. Radar uses radio waves which penetrate rain better.
Step 2: Identify the most reliable sensor for moving object detection in rain
Radar remains reliable in rain due to its radio wave technology, making it best to detect moving objects when LiDAR fails.
Final Answer:
Radar, because radio waves penetrate rain better than light -> Option A
Quick Check:
Radar works best in rain for detection [OK]
Hint: Radar waves pass through rain better than light or cameras [OK]
Common Mistakes:
Assuming cameras work best in rain
Thinking LiDAR is unaffected by weather
Believing all sensors fail equally in rain
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.