Complete the code to declare a Boolean variable named isSunny and assign it the value true.
val isSunny: Boolean = [1]The Boolean value true in Kotlin is lowercase without quotes. Quotes would make it a String.
Complete the code to check if isRaining is false using the logical NOT operator.
if ([1]isRaining) { println("No rain today!") }
not keyword which is not valid syntax in Kotlin.~ which is a bitwise operator, not logical NOT.The logical NOT operator in Kotlin is ! placed before the Boolean variable.
Fix the error in the code to correctly combine two Boolean conditions with the AND operator.
if (isWeekend [1] isHoliday) { println("Day off!") }
and keyword which is not a valid operator in Kotlin.& which is bitwise AND, not logical AND.The logical AND operator in Kotlin is &&. Using and or single & is incorrect for Boolean logic.
Fill both blanks to create a Boolean expression that is true if isCold is true or isSnowing is true.
if (isCold [1] isSnowing) { println("Wear warm clothes!") }
&& which requires both conditions to be true.== or != which do not combine Boolean logic.The logical OR operator in Kotlin is ||. It returns true if either condition is true.
Fill all three blanks to create a Boolean expression that is true only if isWeekend is true, isHoliday is false, and hasPlans is false.
if (isWeekend [1] !isHoliday [2] !hasPlans) { println("Free day to relax!") }
|| which makes the condition true if any one is true.To ensure all conditions must be true, use the logical AND operator && between each condition.