- Fork the assignment repo
- Clone your Fork to your machine
- Complete the lab
- Push your changes to your Fork
- Submit a Pull Request back to the assignment repo
- Paste a link to of your Fork on Canvas and submit
What will be printed when the code below is run? Select all that apply.
let conditionOne = !(4 < 5) || !(3 > 8)
let conditionTwo = !(!true)
if conditionOne {
print("A")
} else if conditionTwo {
print("B")
}
if conditionTwo {
print("C")
}
print("D")
- A
- B
- C
- D Answer = A,C,D
What will the code block below print? Select all that apply:
let appInfo = (name: "myCoolApp", version: 0.4)
switch appInfo {
case (_, 0.0..<1.0):
print("\(appInfo.0) hasn't released yet")
case ("myCoolApp", _):
print("Thanks for looking at myCoolApp!")
default:
print("I'm not quite sure what you are looking at")
}
- appInfo.0 hasn't released yet
- myCoolApp hasn't released yet
- Thanks for looking at myCoolApp!
- I'm not quite sure what you are looking at
- It will give a compile-time error
Answer= myCoolApp hasnt released yet
What will be printed to the console when the code below is run? Select all that apply.
let x: Int = 4
switch x {
case 0..<4:
print("A")
case 5..<10:
print("B")
case is Double:
print("C")
default:
print("D")
}
- A
- B
- C
- D
Answer= D
What are the errors in the code below for the switch statement? Select all that apply.
let candyType : String = "skittles"
switch candyType {
case "mAndM":
print("Melts in your mouth, not in your hand")
case "skittles":
print("Taste the rainbow")
case "snickers":
print("Hungry? Grab a Snickers")
}
- No parentheses around the conditions
- No opening and closing brackets in each of the cases
- No default case in the switch statement
- No print statement right outside the switch statement
Answer= No default case in the switch statement
Given the current weather conditions (rain, sunny, snow), use a switch statement to print an appropriate message to the user
let currentWeather = "rain"
// enter code below
let currentWeather = "rain"
switch currentWeather {
case "rain":
print("bring your umbrella")
case "sunny":
print("bring sunglasses")
case "snow":
print("bring your snowboots")
default:
print("idk")
}
Given the first name and last name of a Fellow, declare fullName
variable and use string interpolation to concatenate the Fellow's full name and print to the console e.g The Fellow's full name is John Appleseed
let firstName = "John"
let lastName = "Appleseed"
let firstName = "John"
let lastName = "Appleseed"
var fullName = "\(firstName) \(lastName)"
print ("The Fellow's full name is \(fullName)")