📖 Scenario: You work for an electric vehicle (EV) company. Your job is to monitor the battery's State of Health (SOH). SOH tells how healthy the battery is compared to when it was new. It is important to know if the battery needs maintenance or replacement.We will create a simple program to track SOH values for different EV batteries and alert if any battery's SOH falls below a safe threshold.
🎯 Goal: Build a small program that stores SOH values for EV batteries, sets a threshold for safe health, checks which batteries are below this threshold, and prints a warning list.
📋 What You'll Learn
Create a dictionary with battery IDs and their SOH values
Add a threshold variable for minimum safe SOH
Use a loop to find batteries below the threshold
Print the list of batteries needing attention
💡 Why This Matters
🌍 Real World
Monitoring battery health helps EV companies maintain vehicle safety and performance. Early detection of weak batteries prevents breakdowns and extends battery life.
💼 Career
Battery SOH monitoring is a key task for EV maintenance engineers and DevOps teams managing vehicle health data systems.
Progress0 / 4 steps
1
Create SOH data for EV batteries
Create a dictionary called battery_soh with these exact entries: 'EV1001': 92, 'EV1002': 85, 'EV1003': 78, 'EV1004': 88, 'EV1005': 95
EV Technology
Hint
Use curly braces {} to create a dictionary. Each battery ID is a key, and its SOH value is the value.
2
Set the SOH threshold
Create a variable called soh_threshold and set it to 80 to represent the minimum safe SOH value.
EV Technology
Hint
Just assign the number 80 to the variable soh_threshold.
3
Find batteries below the SOH threshold
Create an empty list called batteries_below_threshold. Use a for loop with variables battery_id and soh to iterate over battery_soh.items(). Inside the loop, if soh is less than soh_threshold, append battery_id to batteries_below_threshold.
EV Technology
Hint
Use items() to get both keys and values from the dictionary. Check if SOH is less than the threshold and add the battery ID to the list.
4
Print batteries needing attention
Write a print statement to display the text "Batteries below SOH threshold:" followed by the batteries_below_threshold list.
EV Technology
Hint
Use print("Batteries below SOH threshold:", batteries_below_threshold) to show the result.
Practice
(1/5)
1. What does State of Health (SOH) monitoring primarily measure in electric vehicle batteries?
easy
A. The current speed of the vehicle
B. The remaining battery capacity compared to when it was new
C. The temperature inside the battery pack
D. The total distance the vehicle has traveled
Solution
Step 1: Understand SOH definition
SOH measures how much battery capacity remains compared to its original capacity.
Step 2: Differentiate from other metrics
Speed, temperature, and distance are unrelated to SOH's main purpose.
Final Answer:
The remaining battery capacity compared to when it was new -> Option B
Quick Check:
SOH = Remaining capacity % [OK]
Hint: SOH = battery health as percentage of original capacity [OK]
Common Mistakes:
Confusing SOH with vehicle speed
Mixing SOH with battery temperature
Thinking SOH measures distance traveled
2. Which of the following is the correct way to represent SOH as a percentage in a monitoring script?
easy
A. soh = (battery_capacity / original_capacity) * 100
B. soh = battery_capacity / original_capacity
C. soh = battery_capacity - original_capacity
D. soh = battery_capacity + original_capacity
Solution
Step 1: Calculate SOH as a percentage
SOH is the ratio of current to original capacity multiplied by 100 to get a percentage.
Step 2: Check formula correctness
Only soh = (battery_capacity / original_capacity) * 100 correctly multiplies the ratio by 100 to express percentage.
Final Answer:
soh = (battery_capacity / original_capacity) * 100 -> Option A
Quick Check:
Percentage = ratio * 100 [OK]
Hint: Multiply ratio by 100 to get percentage [OK]
Common Mistakes:
Forgetting to multiply by 100
Using subtraction instead of division
Adding capacities instead of dividing
3. Given the following code snippet, what will be the output?