Swift is a programming language created by Apple. What is its main use?
Think about which devices Apple makes and what language they promote for app development.
Swift is designed by Apple to build apps for their platforms like iPhone, Mac, Apple Watch, and Apple TV.
Look at this Swift code and choose the output it produces.
let greeting = "Hello" let name = "Sam" print("\(greeting), \(name)!")
Check how variables are inserted inside strings in Swift.
Using \(variable) inside a string inserts the variable's value. So it prints 'Hello, Sam!'.
Analyze the code and select the output it produces.
var numbers = [1, 2, 3, 4, 5] let doubled = numbers.map { $0 * 2 } print(doubled)
Remember that map applies a function to each item in the array.
The map function multiplies each number by 2, so the output is [2, 4, 6, 8, 10].
Find the error in this Swift code snippet.
let number: Int = "123" print(number)
Check if the type on the left matches the value on the right.
You cannot assign a String value to an Int variable directly in Swift. This causes a type mismatch error.
Swift is known for safety and speed. Which feature helps achieve this?
Think about how Swift avoids crashes from missing values.
Optionals let Swift safely handle missing or nil values, preventing many common errors and improving safety.