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 PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm Exam 1 Review Fall 2003

(Back to Fall2003 Midterm Review 1)

Answers? Comments? Comments on answers?


Does the variable 'value' get passed back to the function outside the block created by 'for x in list1:'? I know variables that don't get 'return'ed to the command area disappear, but I'm a little confREMOVEDed about the other. Student639

Think about what a for loop and a block actually make a program do. Break it down step by step. Lauren Biddle

There's only one function here. REMOVEDnctions have their own contexts, but not blocks. That's all the same value. Mark Guzdial




ok...im very confREMOVEDed...cannot figure this one out at all,,,,,....can someone pleaaaaaaaaaaaaaaase help me out

Walk it through, one line at a time, writing down the value of the variables at each step. Mark Guzdial


I
you
you
you
you
walrREMOVED
4



a=I, so I is the first line, you is printed four times becaREMOVEDe it is run through the loop four times (range(1,5)), c=walrREMOVED, so walrREMOVED is the next line, the last line is the value. the value is = to 4 becaREMOVEDe 1 is added to the value each time through the loop


thank you lindsay

If you are still having trouble with walking this out, REMOVEDe the "Watcher" button in JES: before you run the code, click on "Watcher". Click "Add Var" and then when prompted type "value". Then execute your recipe. The Watcher will trace out every step that it completes and it will tell you the numerical value of "value" at each step. Lauren Biddle



Link to this Page