Array Sum and Average
Easy
arrays
math
Description
Calculate the sum and average of all numbers in a given list of integers. Return the result as an object (dictionary) with keys 'sum' and 'average'.
Examples
Example:
Input: [1, 2, 3, 4, 5]
Output: { "sum": 15, "average": 3.0 }
Explanation: Sum is 1+2+3+4+5=15. Average is 15/5 = 3.0.
Constraints
- Input is a list of integers.
- The list will not be empty.
- Average should be a float.
Loading...
Test Case 1
Input: [1,2,3,4,5]
Output: {"sum":15,"average":3}
Test Case 2
Input: [10,20,30]
Output: {"sum":60,"average":20}
Test Case 3
Input: [7,7,7,7]
Output: {"sum":28,"average":7}
