Bird
0
0

Consider this code snippet simulating battery swapping availability:

medium📝 Analysis Q13 of 15
EV Technology - Future Battery Technologies
Consider this code snippet simulating battery swapping availability:
stations = {"StationA": 3, "StationB": 0, "StationC": 5}
available = [name for name, count in stations.items() if count > 0]
print(available)
What will be the output?
A["StationA", "StationC"]
B["StationA", "StationB", "StationC"]
C["StationB"]
D[]
Step-by-Step Solution
Solution:
  1. Step 1: Understand the dictionary and list comprehension

    The dictionary shows battery counts at stations. The list comprehension selects stations with count > 0.
  2. Step 2: Evaluate each station's count

    StationA has 3 (>0), StationB has 0 (not >0), StationC has 5 (>0). So only StationA and StationC are included.
  3. Final Answer:

    ["StationA", "StationC"] -> Option A
  4. Quick Check:

    Filter count > 0 = ["StationA", "StationC"] [OK]
Quick Trick: Filter dictionary by positive values to find available stations [OK]
Common Mistakes:
  • Including stations with zero batteries
  • Misreading dictionary keys and values
  • Confusing list comprehension syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More EV Technology Quizzes