Monthly Archives: March 2014

Udacity CS101 – Rounding without if statements hurt my brain


This picture of a baby beaver is unrelated to anything, but I love it so much that I don’t want to forget it existed

We have completed week 1 of the Udacity course, and although I don’t know what is coming in the rest of the course, Udacity seems a lot more like Lynda/Codecademy/Code School/Treehouse than the CS101 Stanford course I did on Coursera. The Stanford course mixed in coding with some computer principles, like bits/bytes, what the parts of a computer are, how everything in a computer boils down to a number, etc. I’m not sure if Udacity will go there at some point, but doesn’t seem so yet.

Having said that, the course is much more modern from a users perspective, it’s a lot more ‘meaty’ (lectures are longer) and as a user you do more work/tasks/quizzes.

So I guess, if anyone asked me which I would recommend, I would have to be lame and say both, because I think they offer really different (and valuable)things.

Below are just a few of the interesting things I’ve learnt or figured out so far in the Udacity course:

How to make a decimal round up or down without an if statement

Note that this hurt my brain. A Lot.

– Add 0.5 to your number

i. If it is less than 0.5, then the whole number will remain the same

ii.If it is 0.5 or greater, then the whole number will increment one

- Make the number a string

- Find the decimal in the string with the find method

- Print the string up to the position of the decimal.

How to check if a string is a palindrome

Treat as an array

- Find the length of the array and divide by 2. This is the halfway mark.

- Use this function of an array[::-1] to read the string backwards

- Look for the first half of the array (up to midpoint) reading the array backwards

If it is a palindrome, that first half string will be found at position 0 from the end.

If it isn’t, the result will be that it can’t find it, and it will return -1

The Most Basic Principle of Writing a Method/Function

This next one is obvious, but was never verbalised to me. I think it will come in useful to get things back to basics, if I struggle writing a function in the future.

To write a method or function, you need to first know

i.What do you want to come out of it at the end? (i.e. what should it return)

ii. What do you need to put into it (i.e. variables)

If you know these two things, you can more easily write the method. (I hope you didn’t just think ‘der’)

Well that’s it for now

Leave a reply

University Computer Science Courses Online

At the Ruby Conference a few weeks ago, I listened to a great talk about “Alternative Routes to becoming a programmer” – and one of these was the idea of watching computer science courses (from universities) online. Many of the university-educated programmers commented afterwards that the first few subjects of a CS degree, were the most useful.

So, I decided to do some of these courses online, and the first one I chose was the Stanford CS 101 online at Coursera.

First of all, popular culture makes me think that Stanford (and I guess Harvard, etc) are full of genius people who were born geniuses, and it was interesting to see that, hey, you know what, this course is at the same kind of level that courses at my uni were! They aren’t a super race of geniuses they are just normal people :)

Ok, that’s quite an irrelevant point, so here are my thoughts about the Stanford CS 101 course:

There was an excellent mix of code and real world relation. All the Treehouse, Codecademy and General Assembly courses I have been doing are about writing code and making it do things. But, CS101 from the first lecture related CS concepts I had heard of, to real examples.

For example, in the first segment we covered both variables AND the idea of color pixels in an image. They showed, using the image, how every single thing in a computer is just reduced to numbers.

I also loved how it explained what different pieces of the computer were, and what they do. Even though I had heard those words a hundred times, RAM/CPU/Hard drive, I had never known how they fit together and what they did.

 I now know what bits and bytes are, and why RGB colours can only go up to 255. 

I understand better about how much room on a computer different programs and files take up, and why that is.

While it taught me to write short programmes in JavaScript, it also taught me a lot of things which are ‘assumed’ or ignored by a lot of the online courses I have taken.

Coincidentally, a lovely female Coder-friend is starting a study group for a Computer Science course through Udacity. We will meet once per week to go through the exercises. I’m super excited because throughout the course you learn to build a search engine – which is related to my work! The course will use Python, not Ruby, so let’s see what happens to my brain when it tries to learn an alternative language.

Leave a reply