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
PostgreSQLv16

Tady se objeví výsledek běhu kódu

Visible tests
1
Input
[1,2,3]
Expected14
2
Input
[]
Expected0
3
Input
[5]
Expected25
4
Input
[-2,2]
Expected8
5
Input
[1,2,3,4,5]
Expected55
6
Input
[10,10]
Expected200
Focus radio
Paused · SomaFM · Fluid