Skip to content

Instantly share code, notes, and snippets.

@phlipper
Created March 11, 2015 01:41
Show Gist options
  • Save phlipper/7f15ca0cae62b0f3b92d to your computer and use it in GitHub Desktop.
Save phlipper/7f15ca0cae62b0f3b92d to your computer and use it in GitHub Desktop.
# 1. assign the number 2015 to a variable named `this_year`
this_year = 2015
# 2. assign the number 2020 to a variable named `event_year`
event_year = 2020
# 3. calculate the difference in years and assign the value to `years_remaining`
years_remaining = event_year - this_year
# 4. use concatenation to create a message which reads:
# There are _ years until the big event.
message = "There are " + years_remaining.to_s + " years until the big event."
# 5. output the previous message, without a newline at the end
print message
# 6. output a newline
print "\n"
# 7. use interpolation to output the following message, ending with a newline:
# I can't wait until _ for the big event... Only _ years to go!
puts "I can't wait until #{event_year} for the big event... Only #{years_remaining} years to go!"
# Nice work! BONUS TIME!
#
# Don't worry at all if you don't finish these before class, you can go back and
# practice more later :)
# 8. create a list named `contact_info` with the following elements:
# * your name
# * your state
# * your zip code
# * number of years (or some number) you have lived in at your address
contact_info = ["Phil", "CA", 96161, 5]
# 9. output the following message:
# Hello!
#
# My name is _. It's nice to meet you.
# I have lived in _ for _ years.
puts "Hello!"
puts "\n"
puts "My name is #{contact_info[0]}. It's nice to meet you."
puts "I have lived in #{contact_info[1]} for #{contact_info[3]} years."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment