0
0
Swiftprogramming~10 mins

Print function for output in Swift - Mini Project: Build & Apply

Choose your learning style9 modes available
Print function for output
📖 Scenario: You want to greet your friends by printing messages on the screen.
🎯 Goal: Learn how to use the print function in Swift to show messages on the screen.
📋 What You'll Learn
Create a variable with a greeting message
Create a variable with a friend's name
Use the print function to show the greeting message
Use the print function to show a combined greeting with the friend's name
💡 Why This Matters
🌍 Real World
Printing messages is the first step in making apps that talk to users.
💼 Career
Knowing how to show output is essential for debugging and user interaction in software development.
Progress0 / 4 steps
1
Create a greeting message
Create a variable called greeting and set it to the string "Hello".
Swift
Need a hint?

Use var greeting = "Hello" to create the variable.

2
Create a friend's name variable
Create a variable called friendName and set it to the string "Anna".
Swift
Need a hint?

Use var friendName = "Anna" to create the variable.

3
Print the greeting message
Use the print function to display the value of the variable greeting.
Swift
Need a hint?

Use print(greeting) to show the greeting.

4
Print a combined greeting with the friend's name
Use the print function to display the combined message: "Hello, Anna!" by joining greeting and friendName with a comma and exclamation mark.
Swift
Need a hint?

Use string interpolation like "\(greeting), \(friendName)!" inside print.