Question 1 of 5
IF (n > 10) { DISPLAY ("big") } ELSE { DISPLAY ("small") }
(a) Result for n = 10? (b) Result for n = 11? (c) Result for n = 9?
Responses receive AI feedback against a rubric after submission. Scores are practice estimates.
IF (n > 10) { DISPLAY ("big") } ELSE { DISPLAY ("small") }
(a) Result for n = 10? (b) Result for n = 11? (c) Result for n = 9?
A battery warning uses charge <= 15.
(a) Write IF/ELSE pseudocode that displays "low" when charge <= 15 and "ok" otherwise. (b) What displays at charge = 15? (c) What displays at charge = 16?
Plausible branches for a freezer alarm:
IF (temp > -10)
{
DISPLAY ("too warm")
}
ELSE
{
DISPLAY ("cold enough")
}
(a) What displays when temp = -10? (b) What displays when temp = -9? (c) Explain the equal-boundary behavior of > versus >= for this alarm.
Fill outcomes for the table. Code: IF (x >= 0) { DISPLAY ("nonneg") } ELSE { DISPLAY ("neg") }
| x | Output |
|---|---|
| -2 | |
| 0 | |
| 5 |
(a) Complete the three outputs. (b) Which row is the equal boundary? (c) Why does that boundary row not display neg?
A robot turns when distance < 5, otherwise goes forward.
(a) Write the IF/ELSE with DISPLAY ("turn") and DISPLAY ("forward"). (b) What happens at distance = 5? (c) Name one value that triggers turn.