Question: 
Write a function to calculate the difference between the squared sum of first n natural numbers and the sum of squared first n natural numbers.


Model's Code:
def sum_difference(n):
    sum_n = n * (n + 1) // 2
    sum_n_squared = sum_i_squared(n)
    return sum_n**2 - sum_n_squared

def sum_i_squared(n):
    return n * (n + 1) * (2 * n + 1) // 6



Sample Correct Code:
def sum_difference(n):
    sumofsquares = 0
    squareofsum = 0
    for num in range(1, n+1):
        sumofsquares += num * num
        squareofsum += num
    squareofsum = squareofsum ** 2
    return squareofsum - sumofsquares


Asserts:
assert sum_difference(12)==5434
assert sum_difference(20)==41230
assert sum_difference(54)==2151270


Tests:
Test 1 of 3: PASS
Test 2 of 3: PASS
Test 3 of 3: PASS

Test 320 of 974: 230/320 (71.875%): success