0
0
Kotlinprogramming~10 mins

Int, Long, Float, Double number types 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 declare an integer variable named age with value 30.

Kotlin
val age: Int = [1]
Drag options to blanks, or click blank then click option'
A30.0
B30L
C30.0f
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Using 30L which is a Long type suffix.
Using 30.0f or 30.0 which are floating point numbers.
2fill in blank
medium

Complete the code to declare a Long variable named distance with value 10000000000.

Kotlin
val distance: Long = [1]
Drag options to blanks, or click blank then click option'
A10000000000
B10000000000L
C10000000000f
D10000000000.0
Attempts:
3 left
💡 Hint
Common Mistakes
Not adding L suffix causes errors or wrong type.
Using floating point suffixes like f or decimals.
3fill in blank
hard

Fix the error in the code by choosing the correct value for a Float variable temperature.

Kotlin
val temperature: Float = [1]
Drag options to blanks, or click blank then click option'
A36.6f
B36.6
C36
D36L
Attempts:
3 left
💡 Hint
Common Mistakes
Using a decimal without f suffix causes type mismatch.
Using integer or Long values for Float variables.
4fill in blank
hard

Fill both blanks to create a Double variable price with value 19.99 and print it.

Kotlin
val price: [1] = 19.99
println([2])
Drag options to blanks, or click blank then click option'
ADouble
Bprice
CFloat
Dcost
Attempts:
3 left
💡 Hint
Common Mistakes
Using Float instead of Double for decimal literals without suffix.
Printing a variable name that was not declared.
5fill in blank
hard

Fill all three blanks to create a map of numbers with their types as strings, filtering only those with value greater than 10.

Kotlin
val numbers = mapOf(
  [1] to "Int",
  [2] to "Long",
  [3] to "Float"
).filter { it.key > 10 }
Drag options to blanks, or click blank then click option'
A15
B20L
C12.5f
D8
Attempts:
3 left
💡 Hint
Common Mistakes
Using suffixes incorrectly or mixing types.
Including numbers less than or equal to 10 which get filtered out.