Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print "Hello, Kotlin!" on the same line.
Kotlin
print([1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using println instead of print when the task asks for same line output.
Forgetting to put the text inside quotes.
✗ Incorrect
The print function outputs text without adding a new line.
2fill in blank
mediumComplete the code to print "Hello, Kotlin!" and move to the next line.
Kotlin
println([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the text.
Using single quotes which are for characters, not strings.
✗ Incorrect
The println function prints the text and then moves to the next line. Text must be inside double quotes.
3fill in blank
hardFix the error in the code to print "Kotlin is fun!" on a new line.
Kotlin
println([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using text without quotes causing syntax error.
Using single quotes which are for single characters.
✗ Incorrect
Text must be inside double quotes to be a valid string in Kotlin.
4fill in blank
hardFill both blanks to print numbers 1 to 3 on the same line separated by spaces.
Kotlin
print(1 + [1] + 2 + [2] + 3)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas which are not valid operators here.
Using + without spaces causing numbers to join without spaces.
✗ Incorrect
Adding a space string between numbers concatenates them with spaces.
5fill in blank
hardFill all three blanks to print "Sum: 15" on a new line using variables.
Kotlin
val a = 7 val b = 8 println([1] + ([2] + [3]))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting variables before the string causing wrong output.
Using the string "15" instead of adding variables.
✗ Incorrect
Concatenate the string "Sum: " with variables a and b to print the sum.