0
0
Rubyprogramming~10 mins

What is Ruby - Interactive Quiz & Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print "Hello, Ruby!".

Ruby
puts [1]
Drag options to blanks, or click blank then click option'
A'Hello Ruby'
BHello, Ruby!
C"Hello, Ruby!"
DHello Ruby
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the text.
Using puts without quotes for strings.
2fill in blank
medium

Complete the code to assign the number 10 to variable x.

Ruby
x = [1]
Drag options to blanks, or click blank then click option'
A"10"
Bten
Cx
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Putting numbers inside quotes makes them strings.
Using variable name instead of value.
3fill in blank
hard

Fix the error in the code to add 5 to variable y.

Ruby
y = 7
sum = y [1] 5
Drag options to blanks, or click blank then click option'
A+
B-
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using - instead of + changes the operation.
Using * or / does multiplication or division.
4fill in blank
hard

Fill both blanks to create a hash with keys as symbols and values as strings.

Ruby
person = { [1]: [2] }
Drag options to blanks, or click blank then click option'
A:name
B"Alice"
C"Bob"
D:age
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings as keys without colon.
Not quoting string values.
5fill in blank
hard

Fill all three blanks to define a method that returns the square of a number.

Ruby
def [1](num)
  return num [2] num
end

result = [3](4)
Drag options to blanks, or click blank then click option'
Asquare
B*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of * for multiplication.
Calling method with wrong name.