A Swift Tour Flashcards

1
Q

Write Hello, World!

A

print(“Hello, World!”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Write the variable named myVariable and make it = to 42

A

var myVariable = 42

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write a constant variable named myConstant and make it = to 50

A

let myConstant = 50

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Write an implicit constant integer named implicitInteger and make it = 70

A

let implicitInteger = 70

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Write an implicit constant double named implicitDouble and make it = 70.0

A

Let implicitDouble = 70.0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Write an explicit constant double named explicitDouble and make it = 70

A

Let explicitDouble:Double = 70

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Write and explicit float constant named myFloat = 4.0

A

Let myFloat: Float = 4.0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

let label = “The width is “
let width = 94
Write an implicit constant string named widthLabel = “The width is 94” using the constants label and width

A

let widthLable = label + String(width)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

let apples = 3
let oranges = 5
Write and implicit string constant named appleSummary and use the parentheses to show “I have 3 apples” using the variable apples

A

let appleSummary = “I have (apples) apples”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Create a variable array called shoppingList = “catfish”, “water”, “tulips”, “blue paint”

A

var shoppingList = [“catfish”, “water”, “tulips”, “blue paint”]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

make the second item of a declared variable array called shoppingList = “bottle of water”

A

shoppingList[1] = “bottle of water”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

var occupations = [“Malcolm”: “Captain”,”Kaylee”: “Mechanic”,]

Add a new pair value to the occupations dictionary: Jaine = Public Relations

A

occupations[“Jaine”] = “Public Relations”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Create an empty array called emptyArray using the initializer syntax

A

let emptyArray = String

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Create an empty dictionary named emptyDictionary using the initializer syntax

A

let emptyDictionary = String: Float

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

If type information can be inferred, write an empty array named shoppingList

A

var shoppingList = []

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

If type information can be inferred, write an empty dictionary named ocupations

A

var occupations = [:]