Skip navigation

Monthly Archives: April 2013

Ooohhhh…I need to find this module!




Again I keep running into annoying issues with poorly worded problems or answers.

First, the simple one.

I gave up on trying to finish that last ‘practice exercise’ because it was involving some ‘quadratic equations‘.  Those words scare me.  Big equations freak me out because they are so far beyond my level of mathematical comprehension that I simply cannot fathom.  More on that in a bit.  The simple problem is that when things are not consistent, it’s a little weird.  Our project gives us some decent outlines on how to do things without obviously giving us the direct answer.  The first outline says to “Build a helper function name_to_number(name)”  Ok, that’s easy enough for me to understand and figure out.  The second in the list says Next, you should build a second helper function number_to_name(num).  This too is easy to figure out.  For each of our exercises and this project, we are given an outline that gives us even more guidance. (This is a really good idea to help beginners speed along in their process of learning a new language).  The inconsistency happened when the project template has both of those functions outlined in reverse order.  While theoretically this does not affect the outcome of the program I learned, it is still one more thing I have to question because it doe snot seem logical to have code ‘out of order’, regardless of if it affects it or not.

Second, insufficient definitions.

There are a ton of websites that will give you a definition of a piece of code and what it does.  One would expect that official code documents to give thorough, if maybe overly techie in nature.  Well, how wrong this can be.  Allow me to introduce to the random.randrange(start,stop) function.  You might be able to guess that it creates a random number for a given range, and you would be correct.  You might even guess that the ‘start’ is the first number and the ‘stop’ would be the last number.  And you would fail.  Apparently the ‘stop’ means ‘stop before this number’, or at least that was what I was told.  Me, I think it means ‘count this many numbers and then stop.’, which seems much more logical…if you are starting at 0.  Maybe not so much if your range is starting at a higher number.  So let’s see what the Official Documentation says shall we?

random.randrange(start, stop[, step])
Return a randomly selected element from range(start, stop, step). This is equivalent to choice(range(start, stop, step)), but doesn’t actually build a range object.

I left out step because I wasn’t using it for my program.  Regardless, this really doesn’t mean anything because it doesn’t really define the code, at best it references an older(?)/different way of doing the same thing.  OK, I’ll bite and look up THAT code then.

Return a random element from the non-empty sequence seq. If seq is empty, raises IndexError.

Ok, this still doesn’t explain what the code means, let alone how to use it.

I would like to also keep in mind that this course is aimed at beginners. o_O

It really is annoying when you have to Google everything.  It’s like people are simply getting lazy.  Well guess what, if I have to Google for most of my solutions, don’t bitch if what I find and USE is not all my own code.  I’ll do my best to follow the honour code they put on each page that you have to check-mark before each submission, but until you have a proper course that gives the students all the resources they need, everything is fair game.

There is more but I won’t bother.

Now, this may sound like the worst course in the world but it really isn’t.  I happen to be only focusing on the challenges I have run into.  I didn’t mention how much I have learned BECAUSE of these challenges.  There are 9 practice exercises, of which only 3 gave me headaches like what I have outlined above.  The rest I was able to  figure out and move on to the next one fairly quickly.  Heck, last week I even wrote a little program to help me figure out some things in this goofy little game I am playing on my Galaxy Tab.  Sure it was not much more than a coded spreadsheet but it was my first real stand alone program that I may expand upon to give it more functions as I learn more.

For those that play Galaxy Empire on their Android (or iOS) device, here’s what I got so far.  The rest of you can stop reading…unless you like looking at a whack of lines of code 🙂

Ok, been a bit behind in updating on what I’m doing but first….rant.

I’m doing the Coursera python course and going through a quiz.  I get this:

“Implement the mathematical function f(x) = -5 x5 + 69 x2 – 47 as a Python function. Then use Python to compute the function values f(0), f(1), f(2), and f(3). Enter the maximum of these four numbers.”

What the hell does f(x) mean???  I can’t find any documentation on what this ‘f’ is supposed to do to the “x”.  I’m not a math major by any means but seriously….if you are going to put this into a quiz then have some damn resources so that we can find out what the hell this means…..

Math annoys me.

WordPress to the slight rescue.  See, WordPress smartly suggest tags that may be appropriate to your topic based on words that you type.  It caught “mathematical function” and suggested the Wikipedia article.  I check it out and f(x) represents ‘function x’.  Still don’t know what the hell that means.

Math annoys me.


So I try to write some code that turns this monstrosity into a program:

import math
# this is just my visual reference to the math equation
#f(x) = -5x**5 + 69x**2 – 47

# assign the first f(o)
x = 0
a = (-5*(x**5)) + (69(x**2)) – 47

print f(a)

And I get “TypeError: ‘number’ object is not callable”.  OK fine….none of the documentation we have covers this…so off to Google.

No results found for “TypeError: ‘number’ object is not callable”.

Oh this just keeps on getting better…..I’ve spent about 20mins on this one question……cover your eyes, I’m about to swear…



Update 2

Well got through it….even got 100 on the quiz on the first try too.  I really don’t like learning such a hard way, no matter how well the lessons stick with you afterwards. 😦

So last night i was trying to write my own code, as per the tutorial.  It was really hard at first.  Not necessarily the coding itself, although that was no walk in the park.  No, I was learning about making functions and after the main exercise they then said ”
Write at least one more function of your own design, and run it 10 different ways.”

This kinda threw me.  I mean, what the heck should I write?  What kind of function?  What focus should out be on?  Do i just write a mild variation of the tutorial one?  Give me some direction dammit!

Eventually I decided upon an inventory type of function.   I decided to combine some of my earlier lessons into it.  Namely the raw_input() and read() functions.

What I learned most, besides the syntax of the code, was understanding the differences between a string and an integer.  While I still don’t have a perfect understanding, I do have a better one than before and that is all that matters.

Here is the code I wrote.

# inventory counting function

from sys import argv

script, filename = argv

def inventory(desktop, laptop):
    print “You have %d desktops.” % desktop
    print “You have %d laptops.” % laptop
    print “You could start your own store! \n”

print “How many desktops and laptops did you count?”
desktops_counted = int(raw_input(“Desktops…”))
laptops_counted = int(raw_input(“Laptops…”))

inventory(desktops_counted, laptops_counted)

#need to read a file, then take numbers from that file and print them
print “How many desktops and laptops from last month?”
print “Read file %r:” % filename
print “File contained counts in a ‘desktops on line one,laptops on line two’ format.”
txt = open(filename)
line1 = int(txt.readline())
line2 = int(txt.readline())

I am usually quite good at picking up new things.  Mostly because everything ‘new’ I see is usually related to something else I already know, thus I am merely extending something known with a method that is/was utilized by something else in my life and I am simply applying it in a new way.  When it comes to learning something that is absolutely foreign, this gets much harder to do.  Mind-state, level of difficulty, level of foreignness, previously relatable knowledge and enthusiasm all plays varying roles in how well something is accomplished.

Tonight I ran into some code learning that I just could not grasp (I’m sure this will happen frequently for about a year I suspect…).  I finally gave in just staring at the online exercises and asked on the IRC channel.  Those guys there are pretty damn awesome.  Most are well aware that I am learning and simple do not give me the answer.  They try to guide me to the right answers after checking the exercises.  Most have either gone through them or are well aware of the website that I use (

They tried to give me some directions, some prods, one guy asked if I had learned a certain function yet (I hadn’t) and another suggested a function that is in a newer version of Python which I couldn’t use.  One guy wrote out some code that mostly filled in the blanks, it was an almost complete answer (he was mildly chided for doing so and he will be more reserved next time and I am fine with that, so was he).  It helped me get thinking in the right direction but was not complete.

Another guy sent me a pm (private message) with the exact answer.  Once I saw it, then I completely understood.  I lean best by examples and following those examples.  I was close but needed to add in a bit of knowledge from a completely different exercise.  Sure I didn’t figure it out on my own but once I saw, I really understood the function.  To me, that is just as valid learning as figuring it out on my own.  If I just took it, did it and ignored, then sure…it would a form of cheating.  Yet since that did not happen and I ‘got it’, it’s completely valid 🙂

I can’t stress enough how awesome the #python channel users are and how helpful they have been so far.  I’m pretty sure it’ll be a new online home for me 🙂


So I’m at exercise 16 (of 32) so far and seem to be slowing down as the exercises get a little more complex.  I still have a hard time just ‘doing things’ because I am still not knowledgeable enough to automatically know how to start.  It’s still a bit confusing to ‘just do X’ when you fully haven’t grasped it…or even mostly grasped this concept of ‘x’.

Still, it is good to have an active IRC channel to ask for guidance.  Sometimes they get easily confused when I ask about things that just ‘isn’t done’ in the real world but is important for beginners to learn because of where it is used and the understanding of what it is you are doing.  Think of it as learning to drive.  Sure your instructor told you to make sure your hands are in the 10 o’clock and 2 o’clock position on the steering wheel but when you get into the real world, you got one hand on the gear shift and on one the wheel.  Or one on the wheel and the other hanging out the window.

When I first started to learn to drive, my lessons where in the winter time.  I found my winter coat to be extremely limiting in my movements for controlling the car and such.  Now, it’s no big deal.  Eventually I’ll find these exercises no big deal….till then…it’s uncomfortable and that is where the learning happens.


While I have been playing with technology longer than more kiddies have been around, there are things I still don’t know/never got into.  This includes programming.  Sure, HTML is a type of programming but not in the sense that most current people think when they hear the word.  To this end, I have decided to take up programming.  One of the biggest questions that people like us have is ‘where do I start?’.  Do I start with C++, Python, Java or how about LegoScript(yes, there is such a thing)??

I recall reading somewhere that it really doesn’t matter where you start, so as you start.  I did a cursory search and decided upon Python.   It seemed a reasonable language to learn, nothing to hectic or exotic as far as terms and phrases that are used to both describe and utilized it.

I am currently on my 3rd attempt to learn it.  Why do I say 3rd, well because besides on deciding what to learn, how is just as important.  After a few failed attempts, I am currently following Learn Python The Hard Way website.  Sure has some tutorials, I even found some free PDF’s from O’Reilly Books but so far, this current website is working for me.  Heck, as far as I’m concerned, I have already learned more and better in the last 4 hours than I did in two days with the free books.  Here is a simply program that I wrote, my first 🙂

# Let's calculate how long it would take for me to get to 10,000 of programming

# represents total # of hours needed
master = 10000

# represents # of hours in a day of study
day = 24
awake = 12
forced = 4
personal = 2

# calculate # of days
mastery = master/day
practical_mastery = master/awake
forced_study = master/forced
interested = master/personal# print results
print "They say that to become a master it takes",master,"hours."
print "Mastery with no sleep would take",mastery,"days with no sleep."
print "Hard Practical Mastery would take",practical_mastery,"days at",awake,"hrs of study per day."
print "Real world, forced study Mastery would take",forced_study,"days at",forced,"hrs of study per day."
print "Personal interest study Mastery would take",interested,"days at",personal,"hrs of study per day."