• anonymous
Need assistance defining while statement for Problem set 1 part 3. Can someone please help? I have the code. However, my results are wrong.
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert
Hey! We 've verified this expert answer for you, click below to unlock the details :)
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.
  • chestercat
I got my questions answered at in under 10 minutes. Go to now for free help!
  • e.mccormick
A while loop has a condition and if the condition is true, it does a set of statements. One unique thing about this loop is that it can be made so that it never does anything. Also, it can terminate early if you are not careful. ``` x = 0 while (x > 0): print x x = x - 1 ``` That will never run because x is never > 0. ``` x = 10 while (x > 1): print x x = x - 1 ``` That one will print from 10 to 2 because it ends before it prints 1. And if you mess it up, a while loop can go forever. I am betting your loop is terminating before it is done.
  • anonymous

Looking for something else?

Not the answer you are looking for? Search for more explanations.