NEW
Font size
WorksheetsSwift Playground Programming Quiz
Total questions: 10
Worksheet time: 15mins
What is Swift Playground?
A place you can play quickly
An app on the iPad that helps you learn to code in Swift
An app used to create artwork
An app where you can play games on
What is a code?
A set of instructions for a program to follow
A list of items
A website
A way to make music on the computer
What is the command to move the character forward once?
moveForward()
move forward once
: move forward
robot move foward
Which command is used to turn the switch on?
turnOnSwitch()
Switch()
Why do we need to write functions?
To group a set of commands together and call them
To write more code
To make the code more complicated
To change how the character moves
How can you create the new function turnAround() ?
func turnAround()
{
turnLeft()
turnLeft()
}
func turnAround()
{
2 turnLeft()
}
func turnAround()
{
turnLeft()
turnLeft()
turnLeft()
moveForward()
}
func turnAround()
{
}
turnLeft()
turnLeft()
Which set of commands would work for the function gemAndSwitch() ?
moveForward()
collectGem()
moveForward()
toggleSwitch()
moveForward()
moveForward()
toggleSwitch()
collectGem()
collectGem()
toggleSwitch()
turnleft()
moveForward()
ToggleSwitch()
collectGem()
moveForward()
What is a loop?
A way to write a code once and repeat it a number of times
When you write a command over and over again
A function
A special command
Which one of these shows you how to write code for a loop?
for i in 1 ... 4 {
moveForward()
collectGem()
moveForward()
turnRight()
}
repeat 4 times {
moveForward()
collectGem()
moveForward()
turnRight()
}
copy 4 {
moveForward()
collectGem()
moveForward()
turnRight()
}
moveForward()
collectGem()
moveForward()
turnRight()
Which piece of code will help the character collect all the gems?
for i in 1 ... 5 {
moveForward()
moveForward()
collectGem()
moveForward()
}
for i in 1 ... 3 {
moveForward()
moveForward()
collectGem()
moveForward()
}
for i in 1 ... 5 {
moveForward()
collectGem()
moveForward()
}
for 5 {
moveForward()
moveForward()
collectGem()
moveForward()
}
