+1

Functions and Modules: Module Quiz 3: Questions two

It says, ¨Rearrange the code to define a function that calculates the sum of all the numbers from 0 to its argument.¨ Then here are the choices: A) res + = i B) def sum (x): C) return res D) res = 0 E) for i in range(x): I clicked all of them and every single one was wrong.

4/12/2019 2:18:00 PM

Raven Gerard

1 Answer

New Answer

+6

def sum (x): res = 0 for i in range(x): res + = i return res It sums numbers from 0 to x-1