DEV Community 👩‍💻👨‍💻


Posted on

Square(n) Sum

Complete the square sum function so that it squares each number passed into it and then sums the results together.

For example, for [1, 2, 2] it should return 9 because 1^2 + 2^2 + 2^2 = 9.

Sample Tests-

import codewars_test as test
from solution import square_sum

@test.describe("Fixed Tests")
def basic_tests():'Basic Test Cases')
    def basic_test_cases():
        test.assert_equals(square_sum([1,2]), 5)
        test.assert_equals(square_sum([0, 3, 4, 5]), 50)
        test.assert_equals(square_sum([]), 0)
        test.assert_equals(square_sum([-1,-2]), 5)
        test.assert_equals(square_sum([-1,0,1]), 2)
Enter fullscreen mode Exit fullscreen mode

Solution- ###Python

def square_sum(numbers):
    for i in range(len(numbers)):
    return sum(a)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Take a look at this:


Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠