Yay!! edX started… wait, What?!?

So the edX Python course started 14 hours late…

Anyways, I’m going through it, and one of the first main loop concepts talks about while loops… And the 3rd programming exercise on while loops says that they provide the variable end, use a while loop to calculate the sum of all the integers leading up to end (meaning, if end = 6, we expect 21 [1 + 2 + 3 + 4 + 5 + 6])…

Well, of course I already know a better way to do this… I just blogged about this particular thing a few days ago when talking about Project Euler #1 so I went to use that answer, and of course, it didn’t like it (it was looking for a while statement), so I cheated and wrote:

while True:
    break;

print(end * (end + 1) / 2)

which solved it…

I posted on the site as well that I was disappointed with that particular exercise, as I would think that MIT would actually have an exercise that taught you the proper way to solve the problem (meaning there are lots of good valid reasons to use a while statement, as the prior exercises had done, I felt that they shouldn’t use one that had a better solution than the one they wanted)…

But hey… onwords and upwards!

Home Sweet Home – Motley Crue
Never B Flat, Sometimes B Sharp, Always B Natural