Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if both conditions are true.
Swift
let isSunny = true let isWarm = true if isSunny [1] isWarm { print("Let's go outside!") }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using || instead of && causes the condition to be true if either is true.
✗ Incorrect
The && operator checks if both conditions are true.
2fill in blank
mediumComplete the code to check if at least one condition is true.
Swift
let hasUmbrella = false let isRaining = true if hasUmbrella [1] isRaining { print("You can go outside.") }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using && instead of || requires both conditions to be true.
✗ Incorrect
The || operator means 'or' and returns true if at least one condition is true.
3fill in blank
hardFix the error in the code to negate the condition correctly.
Swift
let isWeekend = false if [1]isWeekend { print("Time to relax!") }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using == instead of ! does not negate the value.
✗ Incorrect
The ! operator negates the Boolean value, making false become true.
4fill in blank
hardFill both blanks to check if the number is between 10 and 20 (inclusive).
Swift
let number = 15 if number [1] 10 [2] number <= 20 { print("Number is between 10 and 20.") }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using || instead of && allows numbers outside the range.
✗ Incorrect
Use >= to check if number is at least 10, and && to combine conditions.
5fill in blank
hardFill all three blanks to check if a character is a vowel (a, e, i, o, u).
Swift
let char: Character = 'e' if char == 'a' [1] char == 'e' [2] char == 'i' [3] char == 'o' || char == 'u' { print("It's a vowel.") }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using && requires all conditions to be true, which is impossible here.
✗ Incorrect
Use || to check if the character matches any vowel.