0
0
iOS Swiftmobile~10 mins

Why Swift is designed for safety and speed in iOS Swift - Test Your Understanding

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

Complete the code to declare a constant in Swift.

iOS Swift
let [1] = 10
Drag options to blanks, or click blank then click option'
Avar
Bconst
Clet
Dfinal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'var' instead of 'let' for constants.
2fill in blank
medium

Complete the code to safely unwrap an optional in Swift.

iOS Swift
if let value = [1] {
  print(value)
}
Drag options to blanks, or click blank then click option'
Avalue
Bvar
Cnil
DoptionalValue
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to unwrap a non-optional or using 'nil' directly.
3fill in blank
hard

Fix the error in the code by choosing the correct type for the variable.

iOS Swift
var name: [1] = "Swift"
Drag options to blanks, or click blank then click option'
AInt
BString
CDouble
DBool
Attempts:
3 left
💡 Hint
Common Mistakes
Using numeric or boolean types for text variables.
4fill in blank
hard

Fill both blanks to create a function that returns the sum of two integers.

iOS Swift
func add(a: Int, b: Int) -> [1] {
  return a [2] b
}
Drag options to blanks, or click blank then click option'
AInt
B+
C-
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction instead of addition.
Returning a wrong type.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that filters keys with values greater than 5.

iOS Swift
let filtered = dictionary.filter { [1], [2] in [3] > 5 }
Drag options to blanks, or click blank then click option'
Akey
Bvalue
Ddict
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong parameter names or filtering by key instead of value.