0
0
Kotlinprogramming~10 mins

Logical operators (&&, ||, !) 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 check if both conditions are true using the AND operator.

Kotlin
val a = true
val b = false
val result = a [1] b
println(result)
Drag options to blanks, or click blank then click option'
A!
B==
C&&
D||
Attempts:
3 left
💡 Hint
Common Mistakes
Using || instead of &&
Using ! which negates a value
2fill in blank
medium

Complete the code to check if at least one condition is true using the OR operator.

Kotlin
val x = false
val y = true
val result = x [1] y
println(result)
Drag options to blanks, or click blank then click option'
A||
B&&
C!
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using && instead of ||
Using ! which negates a value
3fill in blank
hard

Fix the error in the code by using the correct NOT operator.

Kotlin
val flag = true
val result = [1]flag
println(result)
Drag options to blanks, or click blank then click option'
A==
B||
C&&
D!
Attempts:
3 left
💡 Hint
Common Mistakes
Using && or || instead of !
Using == which compares values
4fill in blank
hard

Fill both blanks to create a condition that is true only if a is true and b is false.

Kotlin
val a = true
val b = false
val result = a [1] [2]b
println(result)
Drag options to blanks, or click blank then click option'
A&&
B||
C!
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using || instead of &&
Not negating b with !
5fill in blank
hard

Fill all three blanks to create a condition that is true if either a is false, or both b and c are true.

Kotlin
val a = true
val b = true
val c = false
val result = [1]a [2] (b [3] c)
println(result)
Drag options to blanks, or click blank then click option'
A!
B&&
C||
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up && and ||
Not negating a with !