Here is my work for Exercise 34.
I first answered the questions in strings and use puts to print them to the screen. I then wrote a function check_place(ordinal) that returns a string with the ordinal and cardinal numbers of the specified animal. The function takes an ordinal number as an argument.
1. With what you know of the difference between these types of numbers, can you explain why the year 2010 in “January 1, 2010,” really is 2010 and not 2009? (Hint: you can’t pick years at random.)
Is it because the Gregorian calendar doesn’t start at year zero? Not too sure.
2. Write some more arrays and work out similar indexes until you can translate them.
I feel pretty confident with arrays and indexes, but here’s one more.
3. Use Ruby to check your answers.
Although I am familiar with the concept of arrays and indexes, I had actually not heard of the terms ‘cardinal’ and ‘ordinal’. Zed Shaw makes the terms easy to remember, cardinal for ‘card at random’ (this is the 0 index) and ordinal for ‘being in order’.