0
0
Kotlinprogramming~20 mins

Range operator (..) and in operator in Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Range Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of range and in operator with characters
What is the output of this Kotlin code snippet?
Kotlin
val result = 'c' in 'a'..'f'
println(result)
Afalse
BCompilation error
CRuntime exception
Dtrue
Attempts:
2 left
💡 Hint
Check if the character 'c' lies between 'a' and 'f' inclusive.
Predict Output
intermediate
2:00remaining
Range operator with integers and in operator
What will be printed by this Kotlin code?
Kotlin
val x = 10
val isInRange = x in 1..10
println(isInRange)
Atrue
Bfalse
CCompilation error
DRuntime exception
Attempts:
2 left
💡 Hint
Remember the range 1..10 includes both 1 and 10.
Predict Output
advanced
2:00remaining
Output of reversed range with in operator
What is the output of this Kotlin code?
Kotlin
val num = 5
val range = 10 downTo 1
println(num in range)
Afalse
Btrue
CCompilation error
DRuntime exception
Attempts:
2 left
💡 Hint
Check if 5 is within the range from 10 down to 1.
Predict Output
advanced
2:00remaining
Checking if a value is in a step range
What will this Kotlin code print?
Kotlin
val range = 1..10 step 3
println(7 in range)
ACompilation error
Btrue
Cfalse
DRuntime exception
Attempts:
2 left
💡 Hint
The range includes numbers 1, 4, 7, 10 or not?
Predict Output
expert
2:00remaining
Output of complex range and in operator with floating point
What is the output of this Kotlin code snippet?
Kotlin
val x = 3.5
val range = 1.0..5.0
println(x in range)
ACompilation error
Bfalse
CRuntime exception
Dtrue
Attempts:
2 left
💡 Hint
Check if the range operator (..) works with Double type in Kotlin.