0
0
Swiftprogramming~5 mins

Print function for output in Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the print() function do in Swift?
The print() function shows text or values on the screen (console). It helps you see results or messages while your program runs.
Click to reveal answer
beginner
How do you print a simple message like "Hello, world!" in Swift?
Use print("Hello, world!"). This tells the program to show the words Hello, world! on the screen.
Click to reveal answer
beginner
Can you print numbers using print() in Swift? How?
Yes! You can print numbers directly like print(123). It will show the number 123 on the screen.
Click to reveal answer
beginner
How do you print multiple values or variables in one print() statement?
You can separate values with commas, like print("Age:", age). Swift prints them with spaces between.
Click to reveal answer
intermediate
What is the difference between print() and debugPrint() in Swift?
print() shows user-friendly output. debugPrint() shows more detailed info, useful for debugging your code.
Click to reveal answer
Which Swift code prints the message "Welcome!" to the screen?
Aecho "Welcome!"
Bprint("Welcome!")
Cconsole.log("Welcome!")
DSystem.out.println("Welcome!")
What will print(5 + 3) output in Swift?
A8
B"5 + 3"
C5 + 3
DError
How do you print two variables, name and age, separated by a space?
Aprint(name + age)
Bprint(name.age)
Cprint(name & age)
Dprint(name, age)
Which function shows more detailed info for debugging in Swift?
Aprintln()
Bprint()
CdebugPrint()
DshowDebug()
What happens if you write print() with no arguments?
APrints an empty line
BPrints 'nil'
CCauses an error
DPrints '0'
Explain how to use the print() function in Swift to show messages and variables.
Think about how you tell a friend what you want to show on the screen.
You got /4 concepts.
    Describe the difference between print() and debugPrint() in Swift and when to use each.
    One is for normal messages, the other helps find problems.
    You got /3 concepts.