Complete the code to add two numbers and print the result.
result = 5 [1] 3 puts result
The + operator adds two numbers together.
Complete the code to multiply two numbers and print the result.
result = 4 [1] 7 puts result
The * operator multiplies two numbers.
Fix the error in the code to correctly divide two numbers and print the result.
result = 10 [1] 2 puts result
The / operator divides the first number by the second.
Fill both blanks to calculate the remainder of division and print it.
result = 17 [1] 5 puts result.to_s [2] " remainder"
The % operator gives the remainder of division. The + operator is used here to concatenate the result with a string.
Fill all three blanks to create a hash with keys as numbers and values as their squares, but only for numbers greater than 3.
squares = (1..5).select { |[3]| [3] > 3 }.map { |[3]| [ [1], [2] ] }.to_h
We use x as the key, x * x as the value, and iterate with x over the range. The condition filters numbers greater than 3.