CS 130 Computing Concepts -- Spring 2011
How to prepare for the exam
- Reread the Ruby text
- Redo the labs
- Make sure you can answer the sample questions below
- Get plenty of sleep the night before (it's hard to think when you are overtired).
NB:
- Not all these questions will appear on the exam.
- Not all the questions on the exam appear here.
Sample questions:
- What are the 5 built-in Ruby instructions?
- What are the 4 categories of programming error? Give an example of each.
- What is the syntax of an if statement?
- What is the syntax of a while statement?
- What is the semantics of an if statement?
- What is the semantics of a while statement?
- What are the nine conditions Ruby can check?
- If you want the condition of a while to be the opposite of coinInBag(), what do you put in front of it?
- When you want to either do something or do nothing, what statement do you use?
- When you want to either do one thing or another, what statement do you use?
- When you want to do something repeatedly, what statement do you use?
- When you want to do something repeatedly, but don't want to use while, how do you do it?
- What can you do with iteration that you can't do with recursion?
- What can you do with recursion that you can't do with iteration?
- Which of these are legal identifiers? hi, bye, if, never, ack123, foo, 123go, STOP!, xyzzy, is_OKAY, is_OKAY?, bar
- What does foo mean (in the context of a programming example)?
- Define an instruction to turn right.
- Define an instruction to face east.
- Define an instruction to put down every coin she has.
- Define an instruction to pick up one coin only if Ruby is standing by one.
- Define an instruction to pick up every coin Ruby is standing by.
- Define an instruction to move straight ahead until the front is blocked.
- Assume Ruby has her back to a wall. Define an instruction to move straight ahead until the front is blocked,
then pick up all the coins there, then go back where she started (facing the same way she started). Feel free to use the
instructions you defined in the two previous questions.
- Modify the previous to also pick up every coin she finds.
- Ruby is in a rectangular room with no door. Write an instruction to pick up every coin in the room, take them to the
northwest corner, put them all down, go to the southeast corner, face east, and halt.
- Write an instruction to either put down every coin Ruby has, or pick up every coin on the corner, depending on whether
there are an even or odd number of coins at the current corner. Note: this is not easy (at least at first glance)!
- Write an instruction to create a heart like this, then go home. Assume Ruby starts at home, and
has enough coins in her bag.