This is a MU TIPLE ANST R question. T uch means vou are able to select one or mo
ID: 3739295 • Letter: T
Question
This is a MU TIPLE ANST R question. T uch means vou are able to select one or more answers as beng correct. Note t at this does not necessarily mean that there are multiple correct answers. In anv case, select all the answers you believe are correct. NB: There are no part marks awarded for multiple answer questions.) There is a Prthon list of numeric aluea called collection. Which of the following blocks of Python code would cause the sum of all alues in variable collection to be stored in variable total? total-0 for mystery in collection: total-mystery total-0 for mystery in collection: total (mystery]total + mystery total 0 for mystery in range (len (collection)): total-total mystery total -o for mystery in range (len (collection)1) total-total collection [mystery total -0 for mystery in range (len (collection)) total- total collection[mystery total = 0 for mystery in collection: total-total mysteryExplanation / Answer
Following are correct for the first question.
5.
total = 0
for mystery in range(len(collection)):
total = total + collection[mystery]
range gives numbers from 0 to len(collection)-1 which are indices of values in list collection. Then adding each number to total every time.
6.
total = 0
for mystery in collection:
total = total + mystery
for gives each value in collection directly to the variable mystery and the value is added to total.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.