At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
replying to my own post here! i just saw that polpak suggested i simply count to 100. which this program accomplished. . .
True. Ok, so now make it print each in turn.
i don't know how to do that. eek! i hate asking for you to do this for me but i am unfamiliar with how to print each value.
that's ok. Let me ask you this, what would happen if you removed line 5 from the program?
not sure. . .i'll go remove it and see what happens.
also, while you're doing that. Print out the value of itersLeft before and after the loop
when i remove y=y+x, the print value returned is simply 1. if I print itersLeft before the loop, I get 99. if i print it after, i get 0.
Ok, so itersLeft is 99 before you execute the loop so we can actually remove the y and the x variables entirely and just say itersLeft = 99. That might make things more clear. Now what happens when you print itersLeft inside the loop?
hmmm. i put the statement 'print itersLeft' in the iterative statement and nothing happened.
dpaste your current version of the code and I'll try to figure out what the problem is. It should certainly have done something.
i just redid it. something had gone wrong the first time with my spacing. this time i got a list with values from 98 down to 0. i'm going to increase my itersLeft to 102-x and see what comes back.
wait. You should have removed x and y. You only need to have itersLeft. The x and y variables were specific to the problem trying to be solved in the lecture. For standard iteration you only need 1 counter variable (or some other boolean condition) Just set itersLeft = 99 and see what happens without the x and y
am i just removing y=y+x or am i completely removing y from the program?
you don't need x or y at all. Where you initialize the itersLeft variable, you can just set it directly to 99 (the result of 100-x when x is 1)
alright. now i've gotten a list from 99 to 0. here's the program: http://dpaste.com/490719/
You don't need the x. It's not doing anything useful. See http://dpaste.com/490708/
ah! makes sense. being so new to this, i still don't understand a lot of what i'm doing. so, i'm parroting what i see in lecture until the comprehension sets in!
no problem. I just wanted to simplify the example so you have an easier time understanding how it works. Now, you said that you had a list of numbers from 99 to 0. Techically your version goes from 98 to 0, while mine goes from 99 to 1. See if you can modify my version so that it only goes from 9 to 1.
Also I wanted to clarify something you said. This code does not 'give' a list of numbers. To be correct we can simply say that it will loop 99 times. Each time it loops it will print one number (the current number stored in itersLeft) then change the current number to be the next number.
Or even more correctly. It will loop until itersLeft is NOT greater than 0. And each time it executes the body of the loop we move itersLeft closer to that end case. (itersLeft is less than or equal to 0)
i modified the program so it prints from 9 down to 1. i see how the print statement needs to come before the operation on itersLeft in order to start the list at the current value of itersLeft. i don't have a ton of time to continue working on this so i will need to take a break for now. my next step then will be to have the program only print odd numbers?
yes exactly. Have it print the odd ones.
ok. i'll work on that later today or tomorrow and then come back for help if i need it. are you on the open study forum often?
as a hint, think about how far the next odd number is from the current odd number
this forum? or the main openstudy one?
this forum, i suppose.
I'm here often. I don't use the regular openstudy thing as much.
ok, great! that's really nice of you to hang out in an intro forum in order to help us newbies.
I also tutor elsewhere, and I'm hoping to someday teach, so this is good practice =)
well you're off to a good start helping me so i really appreciate it! and, i hope that if you get a job teaching basic CS, it pays well so you aren't scratching your eye balls out over all the dumb questions for nothing.
It's actually pretty rewarding by itself. I've done things that pay well, and they weren't nearly as much fun.