0
0
Kotlinprogramming~10 mins

Print and println output in Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print "Hello, Kotlin!" on the same line.

Kotlin
print([1])
Drag options to blanks, or click blank then click option'
A"Hello, Kotlin!"
Bprintln("Hello, Kotlin!")
Cprint("Hello, Kotlin!\n")
Decho "Hello, Kotlin!"
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.
2fill in blank
medium

Complete 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'
A'Hello, Kotlin!'
BHello, Kotlin!
C"Hello, Kotlin!"
Dprintln("Hello, Kotlin!")
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the text.
Using single quotes which are for characters, not strings.
3fill in blank
hard

Fix 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'
AKotlin is fun!
B"Kotlin is fun!"
C'Kotlin is fun!'
Dprintln("Kotlin is fun!")
Attempts:
3 left
💡 Hint
Common Mistakes
Using text without quotes causing syntax error.
Using single quotes which are for single characters.
4fill in blank
hard

Fill 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'
A" "
B,
C+
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas which are not valid operators here.
Using + without spaces causing numbers to join without spaces.
5fill in blank
hard

Fill 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'
A"Sum: "
Ba
Cb
D"15"
Attempts:
3 left
💡 Hint
Common Mistakes
Putting variables before the string causing wrong output.
Using the string "15" instead of adding variables.