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

Fall 2007 Test 1 Review: What gets printed

Post questions here.
I tried to predict what the code did, but I was quite puzzled when it returned a 6 when the
print value
line was executed. If value is set to 10 (when q >50, which it is), and we redefine value as value = value - 1, shouldn't JES return a 9 instead of a 6?
Value is set to 10 regardless of q's value. We change value inside the for loop. That is where you will find your answer. Thanks! Brittany Duncan
What's "i"?
i is a value that changes every time through the loop. Don't be confused by the fact that i isn't used or printed out anywhere. We just need it for the for loop to work. The number of times the loop will repeat is the number of items in the list that is returned by range(1,p). Colin Potts
We change value inside the for loop??????????????? i dont see how it can be 6 i dont see where it got changed.

hmm.. i get:
Homestar Rocks!
Everybody
Everybody
Everybody
Everybody
6
Homestar Rocks!

me either,,,,, how it got 6 instead of 9????????
How many times do the commands inside the loop - including the one that subtracts one from value - get repeated????????????? Colin Potts
OHHHHHHHHHHHHHHHHHHHHHHHHHH................................................. :D !




Link to this Page