Week 2a

Well, hello, and welcome to this blogulation. Or slog. Whatever you want to call it. I like to call it “Berkey Colortran”, named for a camera or light or something I saw in the lecture hall. They might hunt me down and litigate my butt for taking the name, but frankly I doubt it. I’m just a kid with a dream, you know? Anyway, here I’ll be reflecting dutifully on my learnings in the course whose code you see at the top of the page.

Yesterday zingarod (IPA: /ˈzɪŋgəˌrɒd/ (yes, that’s how I will refer to him)) informed us of the existence of Exercise 1. I made a note on my phone and thought, “I am so on that tonight.” But when I got home my mind had selectively forgotten the fact and I played DotA 2 instead. When I woke up this morning I realized my grave error and decided to do it this evening. Then a friend cancelled our afternoon piano lesson, so I did it in the afternoon.

The handout says that part a is really only review from 108, but the whole thing was only review from 108. I’d actually say that the chance to use the only new-ish skill we’ve learned so far — that of object-oriented analysis based on a real-world description — was circumvented by the handout’s listing of the actual method names we were to use. What can I say, though? It’s only 2% of the grade.

I had a bit of trouble with the square_root dealie at first. I was like, “The difference between the guesses? Hm hm. So which do I subtract from which?” The progression from this_guess to next_guess not corresponding exactly to greater or lesser value confused me. I did some practical test cases that didn’t clarify things and then I realized I was being dumb and decided to just use the absolute value. Then I forgot to update this_guess for a while, which made the iterations kind of, y’know, pointless. I was so confused that I read the start of the Wikipedia page on Newton’s Method in case I’d misunderstood it. Eventually I caught it. These ridiculous oversights are always what get me…

Anyway, the algorithm itself wasn’t hard. I wondered if I should use a while loop or a for loop and then I realized that since I know exactly how many times I want it to run, I’ll just run a for loop. I was also reminded of the loathsome syntax of loops in Javascript, which I was trying to figure out over the summer. Python is so… clean. And delicious.

The second part was okay too. When zingarod wrote in his handout that we could “probably omit” the __init__ method, I thought, “Trouble’s on the horizon, boys.” So I made an __init__ method just to be safe. But then I had to admit to myself that it didn’t have anything to do, so I just wrote “pass”. Later zingarod confirmed my curiosity that the result is in fact the exact same (except, of course, that you could require parameters if you define it). But my fears were assuaged.

I don’t know, there’s not a lot to say about it. I put in the wrong slash for a long time with my newline. See what I mean about ridiculous oversights? I also decided once and for all that I prefer the string “format” method over concatenation through addition by a ratio of maybe 997:1. After all, allowing math operators on strings is intuitively sick. Consider the following: ‘crumbl’ + ‘e’ == ‘crumble’ but ‘crumble’ – ‘e’ raises an error. This just goes to show that the application is not natural.

In other news, for another ridiculous oversight I had Python choose the minimum between the int parameter and 0 instead of the maximum to avoid negative strings. I fixed it when every call mysteriously turned up the empty string. Also, at first I did this to the parameter itself. Then I realized that the automarker might be tricksy and check if I screwed with my input at any point, so I just did it in the actual calculation.

Well, I guess that’s enough for one post, especially an unmarked one for the first week. Till next time, folks & artichokes.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s