Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.


This page removed for FERPA compliance
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm Exam 1 Review Spring 2005: Tracing the printing

Post your answers, questions, comments, comments on answers, suggestions, suggestions on questions, etc.

Back to Spring2005 Midterm 1 Review



I
you
you
you
you
WalrREMOVED
4

I
you
you
you
you
WalrREMOVED
4

>>>I
>>>you
>>>you
>>>you
>>>you
>>>walrREMOVED
>>>4
Make sure you do not capitalize the word "walrREMOVED" since it is not capitalized in the original function. Victor Du

i don't understand where the number 4 is comming from

I don't understand how people are getting these answers...Is anyone allowed to tell REMOVED where to look this stuff up??

BecaREMOVEDe you have printed the word "you" at position "b" four times, and the initial value is equal to 0, so, if you trace the little blocked paragraph, you'll know that everytime you print the word "you," 1 is added to 0, so after the word is printed 4 times, the result would be 0+4= FOUR. Right? Victor Du

First it says to print a. a represents I, so I is printed. Then there is a list1 created which contains [1,2,3,4] (remember Range does not return include the last value in the list. Then a value is set to 0. The for loop will run foru times, once for x = 1,2,3,4 Each time it prints b (or you) and incrememnts value by 1, so value = value +1 or (1=0+1 then 2=1+1 then 3+2+1 then 4+3+1) So when the for loop is finished running, value is equal to 4. There is then a print c statement, so walrREMOVED is printed, and then print value (which is 4) so 4 is printed. To figure this out, all you need to do is step through the function one line at a time and do what it says to do. Student1594



Link to this Page