Lesson 1Swift Basics

Hello Swift

Welcome to Swift!

Swift is Apple's powerful and intuitive programming language for iOS, macOS, watchOS, and tvOS. Let's start with the classic "Hello, World!" program!

What is Swift?

  • Created by Apple - Swift was introduced in 2014
  • Safe - Designed to eliminate common programming errors
  • Fast - Compiled language with excellent performance
  • Expressive - Clean and modern syntax

The print() Function

The print() function displays text on the screen. It's the simplest way to output information in Swift!

  • Put your text inside double quotes: "Hello"
  • Use \(variable) to insert values
  • Each print statement creates a new line

Why Learn Swift?

Swift lets you build amazing apps for iPhone, iPad, Mac, Apple Watch, and Apple TV. It's beginner-friendly yet powerful enough for professional developers!

main.swift
// My first Swift program!
print("Hello, World!")

// You can print multiple things
print("Welcome to Swift!")
print("Let's learn programming!")

// Print numbers too
print(42)
print(3.14159)

// String interpolation - insert values into strings
let name = "Swift"
print("Hello, \(name)!")

// You can do math inside print
print("5 + 3 = \(5 + 3)")

Try It Yourself!

Print your name and a greeting message using the print() function. Try using string interpolation too!