
# Data Types Practice Worksheet

Record the answers to this worksheet in any file or on a piece of paper. This worksheet will not be turned in, so it does not need to be in a specific format. This worksheet will be reviewed on its due date.


## Ruby Operations on Basic Data Types

Without putting the code into a Ruby script or IRB, predict the output and data type of the following:

1.  Value __________   Data Type: _________  

    ```ruby
    num = 27
    num = num + 5
    num
    ```

1.  Value __________   Data Type: _________  


    ```ruby
    num = 2
    num = num + num + 2
    num
    ```
1.  Value __________   Data Type: _________  


    ```ruby
    num = "4"
    num = num + num
    num
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    cool_thing = "dinosaur"
    awesome_thing = "astronaut"
    rad_thing = cool_thing + " " + awesome_thing
    rad_thing
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    num = 2
    num = num * num
    num = num * num
    num
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    num = 27
    answer = num % 3
    answer
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    num = 100
    num = num / 2
    num = num / 2
    num = num / 2
    num
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    num = 100.0
    num = num / 2
    num = num / 2
    num = num / 2
    num
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    num = 5.0
    num = num * 2 + 3
    num = num / 2
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    answer = :dan
    answer
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    list = ["Pikachu", "Bulbasaur", "Squirtle", "Charizard"]
    list
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    list = ["Pikachu", "Bulbasaur", "Squirtle", "Charizard"]
    list[3]
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    list = ["Pikachu", "Bulbasaur", "Squirtle", "Charizard"]
    list[1]
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    list = ["Pikachu", "Bulbasaur", "Squirtle", "Charizard"]
    list.length
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    list = ["Pikachu", "Bulbasaur", "Squirtle", "Charizard"]
    list.first
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    list = ["Pikachu", "Bulbasaur", "Squirtle", "Charizard"]
    list[4]
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    list = ["Pikachu", "Bulbasaur", "Squirtle", "Charizard"]
    list[-1]
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    pikachu = {
	  name: "Pikachu",
	  type: :electric,
	  species: "Mouse Pokemon",
	  height: 0.41,
	  weight: 6.0,
	  id: 25
    }
    pikachu
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    pikachu = {
	  name: "Pikachu",
	  type: :electric,
	  species: "Mouse Pokemon",
	  height: 0.41,
	  weight: 6.0,
	  id: 25
    }
    pikachu[:name]
    ```

1.  Value __________   Data Type: _________  

    ```ruby
    pikachu = {
      name: "Pikachu",
      type: :electric,
      species: "Mouse Pokemon",
      height: 0.41,
      weight: 6.0,
      id: 25
    }
    pikachu[:id]
    ```


## Comprehension Questions

1. Given a variable `list` which is an array:
    * How would you print the last element of the array?   
    * How about the first?
1. Compare and contrast arrays and hashes. How are they similar, and how do they differ?
