Question 1 of 25
Hints left: 3
Q1
What is the output of the following code snippet? x = 1 loop do puts x x += 1 break if x > 5 end
Q2
What is the purpose of the loop keyword in Ruby?
Q3
What is the output of the following code snippet? for i in 1..5 print i, " " end
Q4
Which loop in Ruby allows you to execute code while a condition is true?
Q5
In Ruby, what does the `break` keyword do when used within nested loops?
Q6
What does the unless keyword do in Ruby?
Q7
In Ruby, what is the purpose of the `case` statement when combined with `when` clauses?
Q8
In Ruby, which of the following is NOT a valid loop construct?
Q9
What does the `retry` keyword do when used within a loop in Ruby?
Q10
Which of the following is used to create a range in Ruby?
Q11
Which of the following is NOT a logical operator in Ruby?
Q12
Which of the following is used to define a block of code that executes repeatedly until a condition is met in Ruby?
Q13
In Ruby, what does the `elsif` keyword allow you to do?
Q14
In Ruby, what does the `else` keyword do?
Q15
What does the `retry` keyword do in Ruby?
Q16
Which keyword in Ruby is used to exit a loop prematurely?
Q17
In Ruby, what does the `case` statement allow you to compare against?
Q18
In Ruby, what does the `elsif` keyword do?
Q19
In Ruby, which of the following is used to handle multiple conditions with one expression?
Q20
What does the `next` keyword do in a loop in Ruby?
Q21
What is the output of the following code snippet? x = 5 while x > 0 puts x x -= 1 end
Q22
In Ruby, what does the `until` keyword do?
Q23
Which of the following is NOT a valid way to exit a loop in Ruby?
Q24
In Ruby, what is the purpose of the `redo` keyword?
Q25
What is the purpose of the next keyword in a loop in Ruby?