Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if a number is positive.
Flutter
if (number [1] 0) { print('Positive'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' causes wrong logic.
Using '==' checks only for zero.
✗ Incorrect
The condition should check if the number is greater than zero to be positive.
2fill in blank
mediumComplete the for loop to print numbers from 0 to 4.
Flutter
for (int i = 0; i [1] 5; i++) { print(i); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' prints 0 to 5, which is one extra.
Using '>' causes the loop to never run.
✗ Incorrect
The loop should run while i is less than 5 to print 0 to 4.
3fill in blank
hardFix the error in the while loop condition to stop at 3.
Flutter
int count = 0; while (count [1] 3) { print(count); count++; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' excludes 3 from the loop.
Using '>' causes the loop to never run.
✗ Incorrect
The loop should run while count is less than or equal to 3 to include 3.
4fill in blank
hardFill both blanks to create a for loop that prints even numbers from 2 to 6.
Flutter
for (int i = [1]; i [2] 6; i += 2) { print(i); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' excludes 6 from printing.
Starting at 1 prints odd numbers.
✗ Incorrect
The loop starts at 2 and runs while i is less than or equal to 6 to include 6.
5fill in blank
hardFill all three blanks to create a switch statement that prints the day name for 1, 2, or 3.
Flutter
switch(day) {
case [1]:
print('Monday');
break;
case [2]:
print('Tuesday');
break;
case [3]:
print('Wednesday');
break;
default:
print('Invalid day');
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 4 causes the default case to run.
Mixing numbers changes the output.
✗ Incorrect
The cases should match the day numbers 1, 2, and 3 for Monday, Tuesday, and Wednesday.