0
0
iOS Swiftmobile~10 mins

Variables (let, var) and type inference in iOS 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 constant named name with value "Alice".

iOS Swift
let [1] = "Alice"
Drag options to blanks, or click blank then click option'
Aname
Bvar
Clet
DName
Attempts:
3 left
💡 Hint
Common Mistakes
Using var instead of let for a constant.
Capitalizing variable names incorrectly.
2fill in blank
medium

Complete the code to declare a variable age with initial value 30.

iOS Swift
var [1] = 30
Drag options to blanks, or click blank then click option'
Aage
Blet
CAge
Dvar
Attempts:
3 left
💡 Hint
Common Mistakes
Using let instead of var for a variable.
Capitalizing variable names incorrectly.
3fill in blank
hard

Fix the error in the code by choosing the correct keyword to declare a variable that can change.

iOS Swift
[1] score = 100
score = 150
Drag options to blanks, or click blank then click option'
Afinal
Blet
Cconst
Dvar
Attempts:
3 left
💡 Hint
Common Mistakes
Using let for variables that need to change.
Using JavaScript keywords like const or final.
4fill in blank
hard

Fill both blanks to declare a variable height of type Double with value 1.75.

iOS Swift
var [1]: [2] = 1.75
Drag options to blanks, or click blank then click option'
Aheight
BInt
CDouble
Dvar
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int type for decimal numbers.
Putting the type before the variable name.
5fill in blank
hard

Fill all three blanks to declare a constant greeting with inferred type and value "Hello".

iOS Swift
[1] [2] = [3]
Drag options to blanks, or click blank then click option'
Alet
Bgreeting
C"Hello"
Dvar
Attempts:
3 left
💡 Hint
Common Mistakes
Using var instead of let for constants.
Forgetting quotes around string values.