0
0
Swiftprogramming~10 mins

Semicolons are optional behavior in Swift - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print a message without using a semicolon.

Swift
print("Hello, Swift")[1]
Drag options to blanks, or click blank then click option'
A.
B;
C:
D(nothing)
Attempts:
3 left
💡 Hint
Common Mistakes
Adding a semicolon when it is not required.
Using other punctuation marks like colon or period.
2fill in blank
medium

Complete the code to declare two variables on the same line using a semicolon.

Swift
var a = 5[1] var b = 10
Drag options to blanks, or click blank then click option'
A;
B:
C,
D.
Attempts:
3 left
💡 Hint
Common Mistakes
Using a comma instead of a semicolon.
Using a colon or period which are not statement separators.
3fill in blank
hard

Fix the error by adding or removing the semicolon correctly.

Swift
let x = 10[1]
let y = 20
Drag options to blanks, or click blank then click option'
A;
B:
C(nothing)
D,
Attempts:
3 left
💡 Hint
Common Mistakes
Adding a semicolon when it is not needed.
Using colon or comma which cause syntax errors.
4fill in blank
hard

Complete the code to write two print statements on the same line correctly.

Swift
print("Hello"); print("World")[1]
Drag options to blanks, or click blank then click option'
A;
B(nothing)
C:
D,
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas or colons instead of semicolons.
Adding a semicolon after the last statement unnecessarily.
5fill in blank
hard

Complete the code to declare three variables on the same line correctly.

Swift
var x = 1; var y = 2; var z = 3[1]
Drag options to blanks, or click blank then click option'
A;
B(nothing)
C:
D,
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas or colons instead of semicolons.
Adding a semicolon after the last statement unnecessarily.