Complete the code to check if the number is positive.
let number = 5 if number [1] 0 { print("Positive number") }
The condition number > 0 checks if the number is positive.
Complete the code to print "Even" if the number is divisible by 2.
let number = 8 if number % 2 [1] 0 { print("Even") }
The condition number % 2 == 0 checks if the number is even.
Fix the error in the if-else statement to print "Adult" if age is 18 or more.
let age = 20 if age [1] 18 { print("Adult") } else { print("Minor") }
The condition age >= 18 correctly checks if age is 18 or older.
Fill both blanks to print "Child" if age is less than 13, otherwise "Teen or Adult".
let age = 10 if age [1] 13 { print("Child") } [2] { print("Teen or Adult") }
The first blank uses '<' to check if age is less than 13. The second blank is the keyword else for the alternative case.
Fill all three blanks to print "Positive", "Negative", or "Zero" based on the value of number.
let number = 0 if number [1] 0 { print("Positive") } else if number [2] 0 { print("Negative") } [3] { print("Zero") }
The first blank checks if number is greater than zero. The second blank checks if number is less than zero. The third blank is the else keyword for zero.