Add the Squares
Sometimes each value needs to be strengthened before you total it, like squaring every number first. Write sum_of_squares, which takes a list of numbers nums and returns the sum of the squares of all elements. If the list is empty, the sum is 0.
Примеры
Ввод
[1, 2, 3]Вывод
14Ввод
[]Вывод
0Ввод
[5]Вывод
25Нужно реализовать
def sum_of_squares(nums: list[int]) -> int:
Теги
matharraylists
Inicia sesión para ver tu historial de envíos
Iniciar sesiónInicia sesión para usar el AI Mentor
Iniciar sesiónVisible tests
1
Input
[1,2,3]Expected
142
Input
[]Expected
03
Input
[5]Expected
254
Input
[-2,2]Expected
85
Input
[1,2,3,4,5]Expected
556
Input
[10,10]Expected
200Focus radio
Paused · SomaFM · Fluid