Getting Started with App Development [Section 4: Operators] Flashcards
Use the ______ operator to assign a value
=
e.g.,
let favoritePerson = “Luke”
The = operator is also used to _______ or reassign a value
modify
e.g.,
The following code declares a shoeSize variable and assigns 8 as its value. The value is then modified to 9:
var shoeSize = 8
shoeSize = 9 // Reassigns shoeSize to 9
When you use the ______ operator (/) on Int values, the result will be an Int value rounded down to the nearest whole number
division
e.g.,
The following code declares a shoeSize variable and assigns 8 as its value. The value is then modified to 9:
var shoeSize = 8
shoeSize = 9 // Reassigns shoeSize to 9
If you explicitly declare constants or variables as ________ values, the results will include decimal values
Double
e.g.,
let x: Double = 51
let y: Double = 4
let z = x / y // z has a value of 12.75
You can use a ________ ________ operator to modify a value that’s already been assigned
compound assignment
The compound assignment operator adds the ____ operator after an arithmetic operator
=
e.g.,
myScore += 3 // Adds 3 to myScore
myScore -= 5 // Subtracts 5 from myScore
myScore *= 2 // Multiples myScore by 2
myScore /= 2 // Divides myScore by 2
You can’t ______ and match number types when performing mathematical operations
mix