You wrote an assessment of learning (mini-test) on the difference between variables and constants, selecting data types, and using operators today.

Depending on the sheet you received, you wrote one of four versions:

VersionColour of paper
AYellow
BGreen
CBlue
DWhite

You can compare the answers you gave to these example solutions below.

NOTE

Choices for variable names might differ.

Version A

Part A

// 1) Unchanging inputs
let first = 14
let second = 5
 
// 2) Results (unchanging), in the given order
let total = first + second
let difference = first - second
let product = first * second
let wholeNumberQuotient = first / second       // 14 / 5 β†’ 2
let leftover = first % second                   // remainder β†’ 4
let scaledSumTimesThree = (first + second) * 3  // (14 + 5) * 3 β†’ 57

Part B

// 1) Changeable starting value
var points = 60
 
// 2) Updates in order
points += 9     // 69
points *= 3     // 207
points -= 20    // 187
points /= 4     // whole-number division β†’ 46
let leftoverAfterGroupingBy4 = points % 4  // remainder of current points Γ· 4 β†’ 2

Part C

// 1) Event title (does not change at runtime for the current event)
let eventTitle = "Guest Lecture"		// String
 
// 2) Number of people currently inside (changes as people enter/leave)
var currentAttendance = 0			// Int
 
// 3) Maximum seating capacity (fixed for the room)
let maxSeatingCapacity = 350		// Int
 
// 4) Ticket price (shown as a whole number here)
let ticketPrice = 25.50			// Double

Version B

Part A

// 1) Unchanging inputs
let first = 18
let second = 7
 
// 2) Results (unchanging), in the given order
let product = first * second
let leftover = first % second
let total = first + second
let wholeNumberQuotient = first / second     // 18 / 7 β†’ 2
let scaledDiffTimesFour = (first - second) * 4
let difference = first - second

Part B

// 1) Changeable starting value
var points = 75
 
// 2) Updates in order
points *= 2     // 150
points += 8     // 158
points /= 5     // whole-number division β†’ 31
points -= 19    // 12
let leftoverAfterGroupingBy5 = points % 5   // remainder of current points Γ· 5 β†’ 2

Part C

// 1) User’s display name (identifier text)
let displayName = "Jordan" 	// String
 
// 2) Steps so far today (changes through the day)
var stepsToday = 0		// Int
 
// 3) Daily step goal (fixed setting)
let dailyStepGoal = 10_000	// Int
 
// 4) Distance walked so far today in km
var distanceWalkedKm = 0.0	// Double

Version C

Part A

// 1) Unchanging inputs
let first = 23
let second = 4
 
// 2) Results (unchanging), in the given order
let wholeNumberQuotient = first / second       // 23 / 4 β†’ 5
let total = first + second
let scaledSumTimesTwo = (first + second) * 2
let leftover = first % second                   // 23 % 4 β†’ 3
let product = first * second
let difference = first - second

Part B

// 1) Changeable starting value
var points = 48
 
// 2) Updates in order
points -= 30   // 18
points *= 4    // 72
points += 12   // 84
points /= 6    // whole-number division β†’ 14
let leftoverAfterGroupingBy6 = points % 6  // remainder of current points Γ· 6 β†’ 2

Part C

// 1) Feature menu item (label text)
let featureMenuItem = "Pasta Primavera"		// String
 
// 2) Meals served so far (changes during lunch)
var mealsServedSoFar = 0				// Int
 
// 3) Maximum meals prepared (fixed for today)
let maxMealsPrepared = 320				// Int
 
// 4) Combo price
let comboPrice = 9.75				// Double

Version D

Part A

// 1) Unchanging inputs
let first = 16
let second = 9
 
// 2) Results (unchanging), in the given order
let leftover = first % second                  // 16 % 9 β†’ 7
let difference = first - second
let total = first + second
let product = first * second
let scaledDiffTimesThree = (first - second) * 3
let wholeNumberQuotient = first / second       // 16 / 9 β†’ 1

Part B

// 1) Changeable starting value
var points = 90
 
// 2) Updates in order
points /= 7    // whole-number division β†’ 12
points += 5    // 17
points *= 5    // 85
points -= 47   // 38
let leftoverAfterGroupingBy7 = points % 7  // remainder of current points Γ· 7 β†’ 3

Part C

// 1) Route name (line label text)
let routeName = "Green Line"	// String
 
// 2) Number of passengers currently on board (changes by stop)	
var passengersOnBoard = 0		// Int
 
// 3) Maximum passenger capacity (fixed for vehicle)
let maxPassengerCapacity = 60	// Int
 
// 4) Fare price
let farePrice = 3.25		// Double