a ← 3 b ← a a ← 4 DISPLAY(b)
b ← ais done).
b ← ais done); b doesn't remember that the 3 came from a so it doesn't change when a is changed.
set
command sets the value of the variable k to the value k – m, not m – k.
mystery function
will report "finished"?
repeat until
loop will stop, and the function will report "finished."
report
command isn't inside the if
.
repeat until
block checks the value of input every time through the loop, not just its initial value.
repeat until
work?
repeat until
block runs the code in its script slot until input = 5, then the computer skips down to the next command, report (
finished)
, without the sprite ever saying 5.
repeat until
block tests the value of input before running the code in its script slot.
if
block do when input is 9?
set
instruction do to the value of input?
if
command run?
if
command will not run.
Imagine you make a variable capitals and use set
to give this list of lists a name:
Which of the following statements are true?
Choose all that apply.
all but first of (capitals)
are lists.
Which of the scripts below will produce the following sprite behavior?
(When you run the script, though, it actually says Abraham Lincoln only once.)
Choose all that apply.
inputList ← [3, -1, 2, 10, -5] FOR EACH item IN inputList { IF(item > 0 AND item * item > 4) { DISPLAY(item) } }
IFinstruction test? What does the
DISPLAYinstruction in this code display?
DISPLAYinstruction in this code display?
PROCEDURE Mystery(numberList, targetNumber) { counter ← 0 FOR EACH number IN numberList { IF(number > targetNumber) { counter ← counter + 1 } } RETURN(counter) } myMathGrades ← [100, 80, 90, 80, 60, 100, 50, 100] Mystery(myMathGrades, 60)
true
if num is less than or equal to 23.
numberis odd:
IF (MISSING CONDITION) { DISPLAY "It is odd." }
number MOD 1 = 0
MODreturns the remainder when the first input is divided by the second. Whether a number is odd or even depends on divisibility by 2.
number MOD 1 = 1
MODreturns the remainder when the first input is divided by the second. Whether a number is odd or even depends on divisibility by 2.
number MOD 2 = 0
number MOD 2returns the remainder when
numberis divided by 2. If that remainder is zero, is the number odd or even?
number MOD 2 = 1
number MOD 2returns the remainder when
numberis divided by 2. If
number MOD 2is 1, then the number is odd.
Mod
gives you the remainder, not the quotient.
When will "Error. Invalid entry." be displayed?
PROCEDURE greaterThanOrEqualTo(a, b) IF(a > b) { RETURN(true) } ELSE { RETURN(a = b) } DISPLAY("Error. Invalid entry.") }
a > bis true.
RETURNdoes. Like
report
in Snap!, RETURNends the procedure. Once it is run, no other code in that procedure is run, and the flow of control returns to the place where the procedure was called.
a > bis false.
RETURNdoes. Like
report
in Snap!, RETURNends the procedure. Once it is run, no other code in that procedure is run, and the flow of control returns to the place where the procedure was called.
RETURNdoes. Like
report
in Snap!, RETURNends the procedure. Once it is run, no other code in that procedure is run, and the flow of control returns to the place where the procedure was called.