Add Array Values
Programs often need to quickly calculate a total, such as a sum of purchases, points, or views. The function simple_array_sum receives a list of integers ar. Return the sum of all elements in the list; if the list is empty, the sum is 0.
Примеры
Ввод
[1, 2, 3, 4, 10, 11]Вывод
31Ввод
[]Вывод
0Ввод
[5]Вывод
5Нужно реализовать
def simple_array_sum(ar: list[int]) -> int:
Теги
arraymath
Log in om je inzendingsgeschiedenis te zien
InloggenLog in om de AI-mentor te gebruiken
InloggenVisible tests
1
Input
[1,2,3,4,10,11]Expected
312
Input
[]Expected
03
Input
[5]Expected
54
Input
[-1,-2,-3]Expected
-65
Input
[0,0,0,0]Expected
06
Input
[5,5]Expected
10Focus radio
Paused · SomaFM · Fluid