Recall & Review
beginner
What does an
until loop do in Ruby?An
until loop repeats the code inside it as long as the condition is false. It stops when the condition becomes true.Click to reveal answer
beginner
How is an
until loop different from a while loop?An
until loop runs while the condition is false, but a while loop runs while the condition is true. They are opposites.Click to reveal answer
beginner
Write a simple Ruby
until loop that prints numbers from 1 to 5.number = 1
until number > 5
puts number
number += 1
end
Click to reveal answer
beginner
Can an
until loop run zero times? When?Yes, if the condition is already true at the start, the
until loop will not run at all.Click to reveal answer
beginner
What keyword ends an
until loop block in Ruby?The
end keyword is used to close the until loop block.Click to reveal answer
What condition does an
until loop check to continue running?✗ Incorrect
An
until loop runs while the condition is false.Which keyword ends an
until loop in Ruby?✗ Incorrect
Ruby uses
end to close blocks including until loops.What will this code print?
count = 3 until count > 5 puts count count += 1 end
✗ Incorrect
It prints 3, 4, and 5 because the loop stops when count becomes 6 (count > 5).
If the condition is true at the start, how many times does an
until loop run?✗ Incorrect
The
until loop runs zero times if the condition is true initially.Which loop is the opposite of
until in Ruby?✗ Incorrect
while loops run while the condition is true, opposite to until.Explain how an
until loop works in Ruby and give a simple example.Think about repeating something until a condition becomes true.
You got /3 concepts.
Compare
until and while loops in Ruby. When would you use each?They are opposites but both repeat code based on conditions.
You got /3 concepts.