![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| 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 |
| 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. |
| 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 |
| 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 |
| 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 |