Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python This is a MULTIPLE ANSWER question, which means you are able to select on

ID: 3883491 • Letter: P

Question

Python

This is a MULTIPLE ANSWER question, which means you are able to select one or more answers as being correct. Note that this does not necessarily mean that there are multiple correct answers. In any case, select all the answers you believe are correct. (NB: There are no part marks awarded for multiple answer questions.)

There is a Python list of numeric values called collection.  Which of the following blocks of Python code would cause the sum of all values in variable collection to be stored in variabletotal?

total0 for mystery in range (len (collection)) total total + mystery total0 for mystery in range (len (collection) -1): total = total + collection [mystery] total0 for mystery in collection: total = total + mystery total0 for mystery in collection: total [mystery] = total + mystery total 0 for mystery in collection: total = mystery total 0 for mystery in range (len (collection)) total total + collection [mystery

Explanation / Answer

The correct piece of codes are:

total = 0
for mystery in collection:
    total = total + mystery

total = 0
for mystery in range(len(collection)):
    total = total + collection[mystery]