Font size
WorksheetsSwift Playgrounds Part 2
Total questions: 15
Worksheet time: 30mins
What is Swift Playground?
A tool used to write a pseudo code for any program
Advanced tool to create applications
Powerful programming language created by Apple
An algorithmic designer tools
What best describes an algorithm?
A step-by-step series of operations
Only calculations that use advanced mathematics
The computer equivalent of rhythm
The same thing as an identifier
What is a sequence ?
specific actions for the computer to perform
Is the order in which the commands are given
is the repeated actions
is the algorithmic thinking skills
What is coding?
The repeated actions in the program
Algorithmic thinking skills
Telling a computer what to do.
None of the above
What is a mistake in code called?
error
debug
bug
misfunction
By writing commands you give instructions to do something. Which command sequence is formatted correctly?
collectGem()
moveForward()
collect Gem ()
move Forward ()
(moveForward)
(collectGem)
moveForward() collectGem()
Longer sequences of code can involve ----------------
less bugs.
more bugs.
fewer variables.
fewer actions.
If the code is not running as intended, what could be the cause of the problem?
bugs
interface
sequence
code
Sometimes we solve coding problems by combining existing commands to create a new behavior. This process is called composition. Which is an example from Swift Playgrounds of composition?
When I told the bot to collectGem()
When I learned to toggleSwitch()
When I created a turnRight() with three turnLeft()
When I write 1 line of code.
With the following code, what would you expect to see happen when you run your code?
func saySomething ( ) {
print ("Functions are awesome")
saySomething ( )
}
saySomething ( )
Functions are awesome, once
Functions are awesome, twice
Functions are awesome, repeated over and over and over...
Nothing
You 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…12
for i in 1…6
for i in 1…4
for i in 1…5
Which of the following should be deleted from the sequence to solve the puzzle?
toggleSwitch()
moveForward()
for i in 1…4 {
turnRight()
()After identifying a pattern of this puzzle, one of your students wants to define a function that will send Byte to collect a single Jen and return to the original center position. Which of the following could be added to “func SolveStair()” to achieve the students objective? Remember that there are multiple ways to solve a puzzle.
moveForward()
collectGem()
turnAround()
moveForward()
moveForward()
turnAround()
moveForward()
collectGem()
turnRight()
moveForward()
collectGem()
turnRight()
moveForward()
turnAround()
moveForward()
turnAround()
collectGem()
moveForward()
Base on the image, what type of codes is used?
Logical AND operator
Logical NOT operator
While loop with an inner while loop
Logical OR operator
While loop nested in for a loop
What is missing to solve this puzzle?
- Use for i in 1…12.
- Add a conditional “if isONClosedSwitch” statement that runs “toggleSwitch()” if true.
- ___________________
- Finally, add a “moveForward()” command.
Use “else if isOnGem” to call “collectGem()” if true.
Use “else if isOnOpenSwitch” to call “toggleSwitch()” if true.
Use a function
Use additional "for" statement
