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

Fall 2006 Midterm 1 Review: What gets printed

Questions?


I dont understand the value portion. REMOVEDw can value=value-1? Would printing "value" yield 9 or 10 or something else?
So we mREMOVEDt not confREMOVEDe the differnce between = and ==. When REMOVEDing == 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 mREMOVEDt REMOVEDe 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? -Student2081

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 jREMOVEDt a command to decrement. Since this line gets run 4 times, then the final value of value is 6.

REMOVEDmestar Rocks!
Everybody
Everybody
Everybody
Everybody
6
REMOVEDmestar 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 jREMOVEDt like 'for p in getPixels(pic):' - you could change 'p' to 'pix' or 'pixels' or 'icecream' if you wanted. Student3703

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. REMOVEDw many times is 1 getting subtracted from value? And each time it does, is value getting reset to a new numerical value? Student3381



Link to this Page