Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if both conditions are true using the AND operator.
Ruby
if a [1] b puts "Both are true" end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using || which means OR instead of AND.
Using ! which means NOT and changes the meaning.
✗ Incorrect
The AND operator in Ruby is &&. It returns true only if both sides are true.
2fill in blank
mediumComplete the code to check if either condition is true using the OR operator.
Ruby
if x [1] y puts "At least one is true" end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using && which means AND instead of OR.
Using == which checks equality, not logical OR.
✗ Incorrect
The OR operator in Ruby is ||. It returns true if at least one side is true.
3fill in blank
hardFix the error in the code by completing the NOT operator usage.
Ruby
if [1] is_valid puts "Invalid input" end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using && or || which are AND/OR, not NOT.
Using == which checks equality, not negation.
✗ Incorrect
The NOT operator in Ruby is !. It reverses the truth value of the expression.
4fill in blank
hardFill both blanks to create a condition that checks if a is true AND b is false.
Ruby
if a [1] [2]b puts "Condition met" end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using || instead of && for AND.
Not negating b when needed.
✗ Incorrect
Use && to check both conditions and ! to negate b.
5fill in blank
hardFill all three blanks to create a condition that checks if x is true OR y is false AND z is true.
Ruby
if x [1] [2]y [3] z puts "Complex condition met" end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up AND and OR operators.
Forgetting to negate y.
✗ Incorrect
Use || for OR, ! to negate y, and && for AND.