NEW
Font size
WorksheetsCSC40/40A - Lesson 4
Total questions: 10
Worksheet time: 7mins
Which of the following statements is used to perform the below task?
"Check if the sum is not equal to 100 or less than 80"
if sum != 100 || sum < 80
if sum != 100 && < 80
if sum != 100 && sum < 80
if sum != 100 || < 80
Which of the following statements is used to perform the below task?
"Check if the sum is equal to 100 and less than 80"
if sum == 100 || sum < 80
if sum == 100 && < 80
if sum == 100 && sum < 80
if sum == 100 || < 80
It results in true only if two statements are true:
OR
AND
NOT
Boolean
It results in true only if one or both operands are true:
OR
AND
NOT
Boolean
It results in true if the value is false, and vice versa.
AND
OR
NOT
Boolean
Which of the following represents Logical Operator AND in Swift?
!
||
&
&&
Which of the following represents Logical Operator OR in Swift?
!
||
&
&&
Which of the following represents Logical Operator NOT in Swift?
!
||
&
&&
Write and use a function collectGemCondition() to move a character forward twice and check if the path is blocked. If the path is blocked and there is a gem, collect the gem, turn left once, then move forward once.
What of the following is correct according to above description:
moveForward()
moveForward()
if isBlocked && isOnGem {
collectGem()
}
turnLeft()
moveForward()
func collectGemCondition()
{
moveForward()
moveForward()
if isBlocked && isOnGem {
collectGem()
}
turnLeft()
moveForward()
}
func collectGemCondition()
{
moveForward()
moveForward()
if isBlocked {
if isOnGem {
collectGem()
turnLeft()
moveForward()
}
}
}
moveForward()
moveForward()
if isBlocked {
if isOnGem {
collectGem()
turnLeft()
moveForward()
}
}
Which of the following represents a symbol that connects two or more Booleans to make conditional decisions more specific and “and,” “or,” and “not” are example of it?
Relational operator
Comparison operator
Mathematical operator
Logical operator
