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

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
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 confused about the other. Jeff Baker

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. Functions have their own contexts, but not blocks. That's all the same value. Mark Guzdial




ok...im very confused...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
walrus
4



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


thank you lindsay

If you are still having trouble with walking this out, use 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