Day 2.1 Exercise 4 Variables and Names

Here’s my work on GitHub.
Here’s the link to the exercise 4.

Ex04 Code
Ex04 Codes
Ex04 irb
Ex04 IRB
Ex04 Shell
Ex04 Output on ShellI

Study Drills

1. I used 4.0 for space_in_a_car, but is that necessary? What happens if it’s just 4?
It’s not necessary, unless there’s a 0.5 person or 0.5 car? I’ve done both the numbers, the output is the same, cept for the decimal point.

2. Remember that 4.0 is a floating point number. It’s just a number with a decimal point, and you need 4.0 instead of just 4 so that is a floating point.

3. Write comments above each of the variable assignments.

4. Make sure you know what = is called (equals) and that it’s making names for things.

5. Remember that _ is an underscore character.

6. Try running ruby from the Terminal as a calculator like you did before and use variable names to do your calculations. Popular variable names are also i, x, and j.
My 2nd picture above shows the irb, how to name variables, and how to use them.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s