An ordered set of instructions. It reads input, follows rules, and produces output.
Workspace
Swift
iOS macOS apps safe systems and modern Apple development
Definition first
What Swift means
Swift is a programming language for writing exact instructions, often used for iOS macOS apps safe systems and modern Apple development. Start with one mental model: input goes through steps and becomes output.
main.swiftRun swift main.swiftHabit Use optionals deliberately and keep playground examples smallA value is data. A variable is the name you use to hold and reuse that data.
A named piece of work. It takes input, does one job, and can return a result.
Swift toolchain is the place that actually runs code from main.swift.
First readable code
Program output
entry point output syntax printprint(42)
Output 42Language lineage
Swift family tree
See where Swift comes from, which languages feel close, and what to learn next.
iOS, macOS, Apple apps, and modern client architecture
Zero base path
Question bank
Search before practice
Pick a stage or search across the open programming bank. Jump straight to the matching drill.
Swift practice 1
Swift question 1. Choose the statement that matches printing a value.
Swift practice 2
Swift question 2. Choose the statement that matches naming a value.
Swift practice 3
Swift question 3. Choose the statement that matches reusable function.
Swift practice 4
Swift question 4. Choose the statement that matches basic collection.
Swift practice 5
Swift question 5. Choose the statement that matches printing a value.
Swift practice 6
Swift question 6. Choose the statement that matches naming a value.
Swift practice 7
Swift question 7. Choose the statement that matches reusable function.
Swift practice 8
Swift question 8. Choose the statement that matches basic collection.
Swift practice 9
Swift question 9. Choose the statement that matches printing a value.
Swift practice 10
Swift question 10. Choose the statement that matches naming a value.
Swift practice 11
Swift question 11. Choose the statement that matches reusable function.
Swift practice 12
Swift question 12. Choose the statement that matches basic collection.
Swift practice 13
Swift question 13. Choose the statement that matches printing a value.
Swift practice 14
Swift question 14. Choose the statement that matches naming a value.
Swift practice 15
Swift question 15. Choose the statement that matches reusable function.
Swift practice 16
Swift question 16. Choose the statement that matches basic collection.
Swift practice 17
Swift question 17. Choose the statement that matches printing a value.
Swift practice 18
Swift question 18. Choose the statement that matches naming a value.
Multiple choice
Swift practice 1
Swift question 1. Choose the statement that matches printing a value.
print(42)
Reference
Patterns for main.swift
swift main.swiftentry point output syntax print
Program output
print(42)
- Run the smallest file first
- Print one known value
- Check the output before adding more code
variables assignment types let
Values and names
let total = 42 print(total)
- Give values readable names
- Keep one idea per line while learning
- Trace the value before changing it
function collection Array
Functions and collections
func add(_ a: Int, _ b: Int) -> Int {
return a + b
}
let scores = [40, 2]
print(scores.count)- Keep functions small
- Return useful values
- Use the common collection before reaching for frameworks