These console commands will prepare you for the day:
# change directory to the course root - hint: type `cd T` and hit the `tab` key
cd TECH601-00/
# make a new directory for today
mkdir day_5| # 1. Create a `day_3` directory under the course directory. | |
| # 2. Save this file under the new folder as `warmup.rb`. | |
| # 3. Assign any string value to a variable. | |
| # 4. Assign any whole number to a variable. | |
| # 5. Assign any decimal number to a variable. |
| # 1. Create a `day_2` directory under the course directory. | |
| # 2. Save this file under the new folder as `warmup.rb`. | |
| # 3. Assign your favorite vacation location to a variable called `destination`. | |
| # 4. Assign the number of days you'd like to visit to a variable called | |
| # `duration`. | |
| # 5. Assign any floating point number to a variable named `price`. |
| # output the values | |
| puts true | |
| puts false | |
| # test true | |
| if true then | |
| puts "true is true" | |
| else | |
| puts "true is not true" | |
| end |
| # our list of countries | |
| countries = [] | |
| countries.push({ | |
| "id" => "AGO", | |
| "name" => "Angola", | |
| "population" => 21_471_618, | |
| "capital" => "Luanda", | |
| "latitude" => -8.81155, | |
| "longitude" => 13.242, |
| # an empty list of countries | |
| countries = [] | |
| # `push` a country on to the list | |
| countries.push({ | |
| "id" => "AGO", | |
| "name" => "Angola", | |
| "population" => 21_471_618, | |
| "capital" => "Luanda", | |
| "latitude" => -8.81155, |
| letters = "a".."g" | |
| vowels = ["a", "e", "i", "o", "u"] | |
| # Loop through each letter and print whether it is a vowel or consonant | |
| # letters.each_with_index do |letter, index| | |
| # if letter == "a" || letter == "e" || letter == "i" || letter == "o" || letter == "u" | |
| # puts "vowel at index #{index}" | |
| # else | |
| # puts "consonant at index #{index}" |
| # Convert all of the following country data in to a Hash, like that of Angola | |
| # Angola | |
| angola = { | |
| "id" => "AGO", | |
| "name" => "Angola", | |
| "population" => 21_471_618, | |
| "capital" => "Luanda", | |
| "latitude" => -8.81155, | |
| "longitude" => 13.242, |
| # Convert all of the following country data in to a Hash, like that of Angola | |
| # Angola | |
| angola = { | |
| "id" => "AGO", | |
| "name" => "Angola", | |
| "population" => 21_471_618, | |
| "capital" => "Luanda", | |
| "latitude" => -8.81155, | |
| "longitude" => 13.242, |
| # DRY this up! | |
| # DRY - Don't Repeat Yourself! :) | |
| # Data Type vs. Data Structure | |
| # | |
| # New Data Type: Hash (or dictionary) | |
| # A Hash is a Data Structure | |
| # Angola: |