Swift Tutorial menu

Swift Quiz

Answer these questions to see how well you know the Swift basics.

How the Quiz Works

  • There are 8 questions from all lessons of this tutorial
  • Pick one answer for each question
  • Read the explanation after each answer
  • Go back to the matching lesson for any question you miss

Quiz Questions

Exercise

Which keyword creates a constant in Swift?

Exercise

How do you put a variable called price inside a string?

Exercise

What does 7 / 2 give when both are Int?

Exercise

What does an optional type such as String? mean?

Exercise

Which statement safely unwraps an optional and leaves the function early if it is nil?

Exercise

Which range includes the numbers 1, 2, 3 and 4 but not 5?

Exercise

What does [1, 2, 3].map { $0 * $0 } return?

Exercise

What is the main difference between a struct and a class?

What Next?

Great work. You now know the core of Swift. The next step is SwiftUI, Apple's way of building app screens, where you will put these skills into real iPhone apps.

Practise by building small things: a tip calculator, a marks report or a to-do list. Small projects teach more than reading alone.

Learn Swift with a teacher

Join the App Development course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp