Skip to content
dreamcode
dreamcode
Map
Average Magnitude
Section challenge · BeginnerPython
Reward: +40 XP
PROBLEM

Average Magnitude

Write a function average_magnitude(magnitudes) that takes a list of float magnitudes and returns their average, rounded to 2 decimal places using round(value, 2). If the list is empty, return 0.0.

Examples
average_magnitude([1.2, 2.4, 0.6])
1.4
average_magnitude([0.03, 1.97, 0.5])
0.83
solution.py
PYTHON
Saved as you type

Tests

0 of 3 passing
  • average check: [1.2, 2.4, 0.6] → 1.4
    average_magnitude([1.2, 2.4, 0.6])
    expected 1.4
  • rounding check: [0.03, 1.97, 0.5] → 0.83
    average_magnitude([0.03, 1.97, 0.5])
    expected 0.83
  • empty list → 0.0
    average_magnitude([])
    expected 0
On the line
+40 XP
Pass all 3 tests to claim it.