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 2006 Midterm 1 Review: What gets printed

Questions?


I dont understand the value portion. How can value=value-1? Would printing "value" yield 9 or 10 or something else?
So we must not confuse the differnce between = and ==. When using == we are testing something logically such does 1 == 2 (The answer by the way is false). To define a value for a variable in python or jython one must use a single = sign. So in the case value starts out at 10 ( value = 10). What happens to value after each for loop. i.e. what is the new value of value after each time you go through the for loop. What is the final value of value that is printed? -Albert d'Heurle

sorry This is in reference to the def testme(p,q,r) problem where value=10

Don't think of "value = value - 1" in a mathematical sense where both sides of the equal sign are the same. That line is saying to "take the number currently stored in the variable value, subtract 1 from it, and store it back in the variable value". This is just a command to decrement. Since this line gets run 4 times, then the final value of value is 6.

Homestar Rocks!
Everybody
Everybody
Everybody
Everybody
6
Homestar Rocks!

what does i mean in the line for i in range(1-p)
i is simply a variable that respresents a number in the range. It's just like 'for p in getPixels(pic):' - you could change 'p' to 'pix' or 'pixels' or 'icecream' if you wanted. Toni Walden

is it integral???


Can you explain why the for i in range(1,p): only makes that part of the program run 4 times instead of 5? In other words, why are there only 4 "Everybody" instead of 5 and 6 is printed instead of 5.
The value of p is 5. So, the 'for' loop has a range(1,5), so i has values 1, 2, 3 and 4 since the range function goes till one less than the ending number which is 5. - Bobby Mathew

why isn't value-1 equal to 9?
Think about where the value-1 is located in regards to indentation, for loops, etc. How many times is 1 getting subtracted from value? And each time it does, is value getting reset to a new numerical value? Liz Helms



Link to this Page