Apple Badge - Swift Code
To demonstrate their learning, you've asked students to take a screenshot of a puzzle, and then use the Markup feature of Photos to add text to the image that reveals their solution. Which of the following are used in this example? Choose two.
Elseblock & Logical NOT operator
To help peers strengthen their debugging skills, one of your students created a code sequence with a bug that prevents Byte from completing his task of toggling the four closed switches. Which of the following should be deleted from the sequence to solve the puzzle?
NOT move forward NOT for i in 1...4
While exploring ways to solve a puzzle, students are left with a code sequence that contains bugs. Which of the following will fix the code sequence and solve the puzzle? CHOOSE TWO
Replace 'for i in 1...3' with 'for i in 1...4' Delete 'turnLeft( )'.
Like rules that apply as long as class is in session, while loops repeat a command or function, as long as a condition is true. Which of the following is an example of a while loop that solves the puzzle?
Right answer - While !isBlocked. { While !isOnGem { MoveForward( ) } CollectGem ( ) TurnLeft ( ) }
Like a coach who only cancels a game if it's raining and windy, students are learning to use logical operators to make conditional decisions in their code more specific. What are some ways logical operators can be used? Complete the following sentences.
The logical OR operator (II) combines two conditions and runs code if AT LEAST ONE is/are true. The logical AND operator (&&) combines two conditions and runs code only if BOTH is/are true. The logical NOT operator (!) inverts the Boolean value of a piece of code.
After identifying a pattern in the Nesting Patterns puzzle, one of your students wants to define a function that will send Byte to collect a single gem and return to the original center position. Which of the following could be added to func SolveStair to achieve the student's objective? Choose two.
WRONG ANSWERS Turn right > moveForward > collectGem > turnRight > moveForward TurnAround > moveForward > turnAround > collectGem > moveForward ALSO WRONG ANSWERS Turn right > moveForward > collectGem > turnRight > moveForward MoveForward > turnAround > moveForward > collectGem
After learning how to name and define functions, your students are exploring ways to use multiple functions to solve a particular challenge. Which of the following is true about the solution to this puzzle? CHOOSE TWO.
WRONG ANSWERS - 'turnAround ( )' can be defined after 'solveStair( )' & 'solveStair( )' is called too many times WRONG ANSWERS - Turnaround can be defined after solveStair & turnLeft could be replaced with turnRight
Like deciding to wear a raincoat or sunglasses, your students are exploring ways to run code based on the value of more than one condition. How can your students use conditional code inside a loop to solve this puzzle?
WRONG ORDER 1 - Add a conditional statement. 2 - Use else if isonGem to call... 3 - Use a for loop 4 - Finally, add a moveForward command. ALSO WRONG ORDER
After learning some fundamental coding concepts, your students are able to use multiple strategies to create algorithms that solve bigger challenges. Which of the following are used in the solution to this puzzle? CHOOSE THREE.
Wrong combo of answers: Logical OR operator Logical NOT operator While loop nested in a for loop
Your students identified a repeating pattern in this puzzle and created a function that solves one instance of the pattern. Which of the following could be used to run the function until the puzzle is solved?
for i in 1...4