Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if a is equal to b.
Ruby
if a [1] b puts "Equal" end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '==' for comparison.
✗ Incorrect
The operator == checks if two values are equal in Ruby.
2fill in blank
mediumComplete the code to check if x is greater than 10.
Ruby
if x [1] 10 puts "x is big" end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' for checking greater than.
✗ Incorrect
The operator > checks if the left value is greater than the right value.
3fill in blank
hardFix the error in the code to check if num is not equal to 5.
Ruby
if num [1] 5 puts "Not five" end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '!=' for not equal comparison.
✗ Incorrect
The operator != means 'not equal' in Ruby.
4fill in blank
hardFill both blanks to check if age is between 18 and 65 inclusive.
Ruby
if age [1] 18 && age [2] 65 puts "Adult" end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '<=' or '>' instead of '>='.
✗ Incorrect
Use >= to check if age is at least 18, and <= to check if age is at most 65.
5fill in blank
hardFill all three blanks to create a hash with keys as uppercase words and values as word lengths greater than 3.
Ruby
result = words.select { |word| word.length [3] 3 }.map { |word| [ [1], [2] ] }.to_h Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'word' instead of 'word.upcase' for keys.
Using '<' instead of '>' for length comparison.
✗ Incorrect
This creates a hash where keys are uppercase words and values are their lengths, but only for words longer than 3 characters.