0
0
Swiftprogramming~10 mins

Var for variables (mutable) in Swift - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Aage
Blet
Cconstant
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'let' instead of a variable name after 'var'.
Using a reserved keyword as the variable name.
2fill in blank
medium

Complete 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'
Alet
B=
Cvar
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which is a comparison operator.
Using 'let' or 'var' which are for declarations.
3fill in blank
hard

Fix 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'
Avar
Bvariable
Clet
Dconst
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'let' which declares a constant.
Using 'const' which is not a Swift keyword.
4fill in blank
hard

Fill 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'
Avar
Blet
Ctemperature
Dtemp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'let' instead of 'var' for mutable variables.
Using a variable name that does not match the instruction.
5fill in blank
hard

Fill 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'
Avar
Bcount
Dlet
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.