Let's think about it this way for a sec
This lesson doesn't teach anything new — it's a practice session where you'll revisit the variables, data types, operators, functions, if-else, loops, lists, and maps from the Basic chapter and actually write the code yourself. Instead of practicing each concept in isolation, these exercises mix them together so you learn to combine them. Working with them together like this will help you understand how to structure real-world logic. Make it a habit to predict the output before you run the code.
Exercises
Task 1: Declare variables of all four types — `int`, `double`, `String`, `bool` — and use string interpolation to print them all in a single sentence. Task 2: Write a function `celsiusToFahrenheit(double c)` that converts temperature using the formula `(c * 9/5) + 32`. Task 3: Use a `for` loop to collect only the even numbers from 1 to 20 into a list. Task 4: Build a `Map<String, int>` with student names as keys and scores as values, then use `if-else` combined with a loop to check each score — "Fail" for below 50, "Pass" for 50 and above.
Code Example
// Task 1 skeleton
void main() {
int age = 0; // TODO
double height = 0.0; // TODO
String name = ''; // TODO
bool isStudent = true; // TODO
print('$name is $age years old.');
// Task 2
print(celsiusToFahrenheit(30));
// Task 3
List<int> evens = [];
// TODO: fill evens with even numbers from 1 to 20
print(evens);
// Task 4
Map<String, int> scores = {
'Aung': 45,
'Su': 78,
'Mya': 60,
};
// TODO: loop through scores and print Pass/Fail
}
double celsiusToFahrenheit(double c) {
// TODO
return 0.0;
}Your console should print the student name/age sentence, the converted temperature, the list of even numbers, and then a Pass/Fail status for each student.Try It in 5 Minutes
Set a 5-minute timer and rewrite Task 2 (the temperature converter) from scratch, without looking at the skeleton code.
A Quick Heads-Up
Type out the tasks by hand without IDE autocomplete — catching your own syntax mistakes will help it stick better.