wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Apple Swift Coding I - Lesson 1 - 6

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

Which option uses more specific names?

a)

dollarPerSandwich * customerCount

b)

numberOfDollars * numberOfPeople

2.

Which of these is an "assignment" in programming?

a)

Giving a name to a particular value, such as: let numberOfSodas = 7

b)

Describing a programming task in a comment, such as: // TODO: Update the sharing message

c)

Running a calculation, such as: 4 + 6 + 9

3.

Which line will be run?


// 10 – 8 +3


18 + 7 + 365

a)

The first line

b)

The second line

c)

Both

d)

Neither

4.

What does it mean to "declare" something in programming?

a)

To write a comment that explains your calculation

b)

To write a hypothesis that you believe to be true

c)

To set a requirement on a performance measurement

d)

To give a name to something for the first time

5.

Which option uses more specific names?

a)

calculatedSpeed < anotherSpeed

b)

currentSpeed <maximumSpeed

6.

Which of these is written in "camel case"?

a)

FIRSTname

b)

first_name

c)

firstName

d)

first.name(camel)

7.

Which of these are strings?

a)

“9.99”

b)

“100%”

c)

Neither

d)

Both A and B

8.

Which of these are strings?

a)

"Happy birthday"

b)

88

c)

Neither

d)

Both A & B

9.

The second line below has a "use of unresolved identifier" error. What does that mean?

let playgroundName = "My Playground"

let welcomeMessage = "Come and play in \(playGroundName)"

a)

The string interpolation is done wrong; it should use a /

b)

You can't repeat names

c)

playGroundName isn't a string

d)

Names need to match capital and lowercase letters; it should be playgroundName

10.

Which of these are strings?

a)

let myLuckyNumber = 42

b)

"\"Curiouser and curiouser, \ "said Alice."

c)

Neither

d)

Both A & B

11.

Which option uses a more specific name?

a)

X

b)

Distance

12.

. Which of these is the escape character to coding in Swift?

a)

/

b)

\

c)

!

d)

ESC

13.

What is the result of the expression "1" + "1"

Hint: Not sure? Open the Strings playground, type it in and try it. That's not cheating: programmers try out little bits of code in Playgrounds all the time.

a)

2

b)

"2"

c)

11

d)

"11'

14.

Identify this part of a playground.

// Qualifying total time

a)

Details you can’t edit

b)

A code comment

c)

A line with an error

d)

Results view

15.

What is a character in programming?

a)

A distinguished coder like Ada Lovelace or Alan Turing

b)

The first 140 ASCII symbols

c)

A letter from A to Z

d)

Treating the next character in a special way

16.

Which of the following is not a benefit of using functions?

a)

They prevent repeated code organization

b)

They can give you infinite loops

c)

They keep your code organized

d)

They make large programs easier to understand

17.

What is the escape character for?

a)

Undoing the last program command

b)

Telling the computer to quit an app

c)

Skipping the rest of the string

d)

Treating the next character in a special way

18.

// My total time

! 81 + 97 + 80b

a)

A code comment

b)

Details you can’t edit

c)

A line with an error

d)

Results View

19.

With the following code, what would you expect to see in the console in a playground?


func saySomething ( ) {

print ("Functions are awesome")

}

a)

Functions are awesome

b)

saySomething

c)

Nothing

20.

Which line is the correct way to declare a function?

a)

let myFunction = func ( ) {

b)

let func = myFunction ( ) {

c)

func MyFunction ( ) {

d)

func = myFunction ( ) {

21.

A representation of almost any character from any language such as French, German, Spanish, Russian also including emoji's.

a)

Escape sequence

b)

Unicode

c)

String interpolation

d)

Quick Look Button

22.

Identify the part of a playground in red.

Side bar

81

81

97

97

80

80

a)

A code comment

b)

Details you can’t edit

c)

A line with an error

d)

Results View

23.

Identify this part of a playground.


Will your time qualify?

a)

A code comment

b)

A line with an error

c)

Details you can't edit

d)

Results view

24.

With the following code, what would you expect to see in the console in a playground?


func saySomething ( ) {

print ("Functions are awesome")

saySomething ( )

}

saySomething ( )

a)

Functions are awesome, once

b)

Functions are awesome, twice

c)

Functions are awesome, repeated over and over and over...

d)

Nothing

25.

What don't programmers like doing?

a)

Coding

b)

Reading

c)

Repeating themselves

d)

Writing

26.

What's another word for the lines of code that a function contains?

a)

Body

b)

Clause

c)

Parameters

d)

Return value

27.

With the following code, what would you expect to see in the console in a playground?


func saySomething ( ) {

print ("Functions are awesome")

}

saySomething ( )

a)

a. Funtions are awesome

b)

a. saySomething

c)

Nothing

28.

Which of these messages belongs in a console instead of in the view that the user sees?

a)

Error - 1000 (kCFURLErrorBadURL):"asdfwefawge.ed"

b)

We can't find the page "asdfwefawge.ed"

29.

Which of these messages belongs in a console instead of in the main app's UI?

a)

Connection restored (now ReachableViaWWAN). Offline time: 1587 secs.

b)

You're back online!

30.

Which of these messages belongs in a console instead of in the main app's UI?

a)

Your changes couldn't be saved.

b)

Mutating an object 0x98126450 after it has been removed from its context