Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if variable a is greater than b.
C Sharp (C#)
bool result = a [1] b; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
== instead of > to compare values.Using
< which means less than.✗ Incorrect
The > operator checks if the left value is greater than the right value.
2fill in blank
mediumComplete the code to check if score is less than or equal to 100.
C Sharp (C#)
if (score [1] 100) { Console.WriteLine("Valid score"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
< which excludes equality.Using
>= which means greater than or equal.✗ Incorrect
The operator <= means 'less than or equal to'.
3fill in blank
hardFix the error in the comparison to check if age is not equal to 18.
C Sharp (C#)
if (age [1] 18) { Console.WriteLine("Age is not 18"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
= which is assignment, not comparison.Using
<> which is not valid in C#.✗ Incorrect
The operator != means 'not equal to' in C#.
4fill in blank
hardFill both blanks to create a dictionary that maps numbers to their squares only if the number is greater than 3.
C Sharp (C#)
var squares = new Dictionary<int, int> {
{ [1], [2] }
}; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 as key which is not greater than 3.
Using a value that is not the square of the key.
✗ Incorrect
The key is 4 (greater than 3) and the value is its square 16.
5fill in blank
hardFill all three blanks to create a LINQ query that selects numbers from 1 to 5 where the number is less than 4 and doubles them.
C Sharp (C#)
var result = from num in Enumerable.Range(1, 5) where num [1] 4 select num [2] [3];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using greater than operator in the where clause.
Using addition instead of multiplication for doubling.
✗ Incorrect
The query filters numbers less than 4 and selects their doubles by multiplying by 2.