0
0
Kotlinprogramming~10 mins

Range operator (..) and in operator 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 create a range from 1 to 5.

Kotlin
val numbers = 1 [1] 5
Drag options to blanks, or click blank then click option'
Auntil
B...
C..
Dto
Attempts:
3 left
💡 Hint
Common Mistakes
Using '...' which is not a valid range operator in Kotlin.
Using 'until' which excludes the end value.
2fill in blank
medium

Complete the code to check if 3 is inside the range from 1 to 5.

Kotlin
val isInRange = 3 [1] 1..5
Drag options to blanks, or click blank then click option'
A==
Bin
Ccontains
Dnot in
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which checks equality, not membership.
Using 'not in' which checks the opposite.
3fill in blank
hard

Fix the error in the code to check if 10 is not in the range from 1 to 5.

Kotlin
val check = 10 [1] 1..5
Drag options to blanks, or click blank then click option'
A!=
Bin
Ccontains
Dnot in
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'in' which checks if the value is inside.
Using '!=' which checks inequality, not range membership.
4fill in blank
hard

Fill both blanks to create a range from 5 to 10 and check if 7 is inside it.

Kotlin
val range = [1] [2] 10
val result = 7 in range
Drag options to blanks, or click blank then click option'
A5
B..
Cuntil
Dto
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'until' which excludes the end value.
Using 'to' which creates a Pair, not a range.
5fill in blank
hard

Fill all three blanks to create a range from 'a' to 'z' and check if 'm' is inside it.

Kotlin
val letters = [1] [2] [3]
val containsM = 'm' in letters
Drag options to blanks, or click blank then click option'
A'a'
B..
C'z'
Duntil
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'until' which excludes the end character.
Using double quotes instead of single quotes for characters.