Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a mutable variable named age with value 25.
Swift
var [1] = 25
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'let' instead of a variable name after 'var'.
Using a reserved keyword as the variable name.
✗ Incorrect
In Swift, var declares a mutable variable. Here, age is the variable name.
2fill in blank
mediumComplete the code to change the value of the variable score to 100.
Swift
score [1] 100
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which is a comparison operator.
Using 'let' or 'var' which are for declarations.
✗ Incorrect
The = operator assigns a new value to a variable.
3fill in blank
hardFix the error in the code to declare a mutable variable name with value "Alice".
Swift
[1] name = "Alice"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'let' which declares a constant.
Using 'const' which is not a Swift keyword.
✗ Incorrect
Use var to declare a mutable variable in Swift.
4fill in blank
hardFill both blanks to declare a mutable variable temperature with value 72.
Swift
[1] [2] = 72
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'let' instead of 'var' for mutable variables.
Using a variable name that does not match the instruction.
✗ Incorrect
var declares a mutable variable, and temperature is the variable name.
5fill in blank
hardFill all three blanks to declare a mutable variable count, assign 10, and then update it to 15.
Swift
[1] [2] = 10 [3] = 15
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'let' to declare a variable that is later changed.
Using different names for the variable in declaration and update.
✗ Incorrect
First, var declares the variable, then count is the name. Later, count is updated to 15.