Thursday, January 31, 2013

The One with the Cats

Hi everyone!

So, it's our second week of classes and things are picking up speed! On Tuesday in class we learned how to make very simple functions with one argument, using "def". After completing all of Dr. Kay's prompts, I started brainstorming about what kind of problem I would make up and solve using a simple function.

That's when I realized I have no creativity in programming yet. At all. Or maybe I do, and I just don't know quite enough to really let it blossom yet because my solution to fixing things on my computer is the 'hand-computer-to-competent-friend-and-plead-for-help' method. So, since I love cats and mine was snuggled up next to me, I had this bright idea to make a function that spit out a random fact about cats if you input a number 1-5. After probably an hour of determination (after I got out of work at 10:30 Wednesday night) and trying to look up python programming tips I decided to modify my idea to one that I wouldn't need Dr. Kay's help with.

I made a function that has an argument that gets multiplied by one of my favorite numbers, 76,863. I know it is completely pointless, but I did get to include a little bit on cats based on my earlier frustration. I guarantee no one else would have come up with my exact solution to multiplying a number by 76,863! And hey, I practiced programming. A whole bunch. Here it is:

 def disapprovingCatFace(anyNumber):
   numberFixed = anyNumber*76863
   print "I am a disapproving cat and I did not like your choice of number (or word). I have multiplied it by 76,863 because that's an awesome number. Here it is: ", numberFixed
   print " /\_____/|"
   print "|      o        o      |"
   print "= __X__ ="
   print "Also, that's my face. Bye now!"


and in Python, it looks lovely!



No comments:

Post a Comment