Introduction to Ruby

I Variables & Data Types

i. Overview & Sneak Peek 1/16
Save and Submit

ii. Data Types: Numbers, Strings, Booleans 2/16

my_num =  25   # Add your code here!

my_boolean =    true # And here!

my_string =     "Ruby"# Also here.

iii. Variables 3/16

my_num = 100

iv. Math 4/16

my_calc = 2**6

v. ‘puts’ and ‘print’ 5/16

puts "Hi"
print "Dream"

II String Methods
i. Everything in Ruby is an Object 6/16
Save and Submit
ii. The ‘.length’ Method 7/16

"Sunakshi".length

iii. The ‘.reverse’ Method 8/16

"Sunakshi".reverse

iv. ‘.upcase’ & ‘.downcase’ 9/16

puts "Sunakshi".upcase
puts "Sunakshi".downcase

III Writing Good Code
i. Single-Line Comments 10/16

# I am full, can't eat more.

ii. Multi-Line Comments 11/16

=begin
This is how we write a multi line comment.
Ruby seems easy.
=end

iii. Naming Conventions 12/16

name = "Sunakshi"

i. Variables & Data Types 13/16

my_name = "Sunakshi"
my_age = 23

ii. Math 14/16

sum = 13 + 379
product = 923 * 15
quotient = 13209 / 17

iii. Strings and String Methods 15/16

name = "Sunakshi".downcase.reverse.upcase

iv. Comments 16/16

#First exercise is over.
=begin
We know little in Ruby by now.
See you in the next exercise.
=end

Save and Submit

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s