ICSOC-8.11.6 Operators, Variables, and Custom Procedures (M)

Easy

ICSOC-8.11.6.1 Arithmetic Operator Blocks: Evaluation Precedence, Numeric Type Coercion, and Nested Expressions

Arithmetic Operator Blocks: Evaluation Precedence, Numeric Type Coercion, and Nested Expressions

Scratch provides four fundamental oval reporter blocks in the Operators palette to perform elementary arithmetic: addition (+), subtraction (-), multiplication (*), and division (/). These blocks accept numbers, variables, or nested reporter blocks within their rounded operand slots and report the calculated scalar result. Unlike traditional textual programming languages that enforce algebraic operator precedence rules (PEMDAS/BODMAS) across an entire line of code, Scratch determines evaluation order purely through geometric block nesting: deeply nested inner operator blocks are fully resolved first, passing their evaluated return values upward to outer containing blocks. Division by zero in Scratch is handled gracefully without crashing the virtual machine, evaluating mathematically to Infinity, -Infinity, or NaN (Not a Number) depending on the numerator’s sign.

In addition to pure numerical computation, Scratch’s arithmetic blocks incorporate automatic dynamic type coercion. If a string containing numeric characters (such as “42”) is inserted into an arithmetic operand slot, the Scratch virtual machine automatically parses and casts the string into an IEEE-754 floating-point number before computing the result. If a non-numeric string (such as “apple”) is passed into an arithmetic block, Scratch coerces the invalid text to 0. Understanding nested operator tree evaluation and string-to-number casting behavior is critical for constructing robust Olympiad-level computational algorithms in Scratch.

Easy
In Scratch, what is the evaluated result of the nested arithmetic reporter block [((10) + (4)) * (2)]?
Option A is correct because Scratch evaluates expressions based on block nesting geometry rather than linear operator precedence. The inner addition block ((10) + (4)) is evaluated first, producing 14. This result is then passed into the outer multiplication block to calculate 14 * 2 = 28. Option B is incorrect because 18 would result from calculating 10 + (4 * 2), which is not the nesting shown. Option C and D represent arithmetic miscalculations.
Medium
How does the Scratch virtual machine handle type coercion when the non-numeric text string “banana” is placed into an operand slot of an arithmetic block, such as [(“banana”) + (5)]?
Option A is correct because the Scratch virtual machine implements automatic dynamic type coercion; when an arithmetic operator receives a non-numeric string that cannot be parsed into a valid number, it silently coerces the text value to 0, resulting in 0 + 5 = 5. Option B is incorrect because Scratch is designed to be error-tolerant and never throws unhandled type mismatch exceptions. Option C is incorrect because numerical operator blocks never perform string concatenation (the [join () ()] block must be used for text concatenation). Option D is incorrect because Scratch does not substitute string length into arithmetic operations automatically.
Tricky
What does Scratch evaluate and report when executing the division block [(15) / (0)]?
Option A is correct because Scratch conforms to IEEE-754 floating-point arithmetic standards in JavaScript; dividing a positive non-zero number by zero yields positive “Infinity” (or “-Infinity” if negative). Option B is incorrect because dividing by zero does not mathematically or natively equate to zero. Option C is incorrect because NaN is returned specifically for undefined operations like 0 / 0, not positive division by zero. Option D is incorrect because Scratch’s runtime catches mathematical limits cleanly without crashing.
Easy

ICSOC-8.11.6.2 The “pick random () to ()” Reporter: Pseudo-Random Number Generation and Type Determination

The

The “pick random () to ()” block is a vital green reporter in Scratch used to introduce stochastic behavior, procedural generation, and dynamic unpredictability into programs. Under the hood, the Scratch engine uses a pseudo-random number generator (PRNG) that produces uniformly distributed numerical values bounded inclusively between the two specified parameters. A critical architectural feature of this block is its dual-mode type determination: if both input parameters are integers (e.g., pick random 1 to 10), Scratch generates an integer result inclusive of both endpoints (1, 2, …, 10). However, if either parameter contains a decimal fraction (e.g., pick random 1.0 to 10 or 0.1 to 0.9), Scratch switches automatically to continuous floating-point generation, returning a high-precision decimal value.

Furthermore, the “pick random” block operates symmetrically regardless of parameter ordering: if the first operand is greater than the second (such as pick random 10 to 1), the Scratch runtime automatically swaps or accounts for the bounds, returning a valid integer between 1 and 10 without throwing an error. Developers frequently leverage this block for game mechanics such as enemy spawning intervals, randomized drop velocities, dynamic damage calculations, and generating unpredictable AI behavior vectors.

Easy
Which set of values can potentially be returned by the reporter block [pick random (1) to (4)]?
Option A is correct because when both inputs to [pick random () to ()] are integers, Scratch operates in integer mode and selects a uniformly distributed pseudo-random integer inclusive of both endpoints (1, 2, 3, and 4). Option B is incorrect because endpoints are strictly inclusive in Scratch. Option C is incorrect because floating-point decimals are only generated if at least one input parameter explicitly contains a decimal point. Option D is incorrect because all intermediate integers are valid outputs.
Medium
What happens if a programmer supplies reversed bounds to the randomization block, calling [pick random (10) to (1)]?
Option A is correct because the Scratch virtual machine handles reversed arguments symmetrically; if the first parameter is numerically greater than the second, Scratch accounts for the bounds (effectively swapping them internally) and picks a valid pseudo-random number in that interval. Option B, C, and D are incorrect assumptions derived from rigid programming languages that do not provide Scratch’s built-in argument normalization.
Tricky
A student wants a sprite to generate random decimal coordinates with high precision. Which block invocation guarantees a continuous floating-point decimal output?
Option A is correct because Scratch inspects the string representations of both arguments; if either argument contains a decimal point (such as 1.0), the random block automatically switches to floating-point mode, generating numbers like 2.71828… rather than discrete integers. Option B and D evaluate strictly in integer mode because both operands are whole numbers. Option C uses [round], which explicitly strips decimal fractions and forces an integer output.
Medium

ICSOC-8.11.6.3 Relational Comparisons and Boolean Logic: Truth Tables, Short-Circuiting, and Predicate Blocks

Relational Comparisons and Boolean Logic: Truth Tables, Short-Circuiting, and Predicate Blocks

Relational comparisons and logical operations form the foundation of conditional decision-making in Scratch. Relational operators are represented as green hexagonal predicate blocks: less than (<), equal to (=), and greater than (>). These blocks evaluate the relationship between two expressions and return a strict Boolean primitive: true or false. In Scratch, the equality block (=) is uniquely case-insensitive when comparing strings; for instance, the expression <"Scratch" = "scratch"> evaluates to true. However, when comparing alphanumeric strings against numbers, Scratch attempts to convert both operands into numbers; if conversion fails, it performs a lexicographical ASCII comparison.

Boolean logical operators—”and”, “or”, and “not”—enable programmers to construct complex compound conditional expressions. The hexagonal “and” block reports true only when both nested conditions are true; the “or” block reports true if at least one condition evaluates to true; and the “not” block inverts the Boolean truth value of its nested argument. In Scratch’s execution model, Boolean blocks can be nested indefinitely to evaluate multi-clause game rules, boundary checks, and collision conditions. In Olympiad programming, mastering Boolean algebra laws—such as De Morgan’s Laws (e.g., [not (A and B)] is logically equivalent to [(not A) or (not B)])—is essential for simplifying complex conditionals and eliminating redundant execution cycles.

Easy
What does the Boolean predicate block [ (10)>>] report?
Option A is correct because the inner relational block <(5) > (10)> evaluates to false (since 5 is not greater than 10). The outer block inverts the Boolean truth value of false to true. Option B is incorrect because it overlooks the negation. Option C and D are incorrect because Scratch Boolean predicate blocks report true or false, not numerical or null primitives.
Medium
How does the Scratch equality block [<[Scratch] = [scratch]>] evaluate string comparisons?
Option A is correct because the Scratch equality predicate block [ = ] performs case-insensitive comparisons when comparing strings, treating uppercase and lowercase letters as identical. Option B is incorrect because case sensitivity is ignored by the [ = ] block in Scratch. Option C is incorrect because [ = ] accepts strings, numbers, and variables. Option D is incorrect because variable scope has no bearing on equality logic.
Tricky
According to De Morgan’s Laws of Boolean logic, which expression is mathematically and logically equivalent to [ 50> and 0>>>]?
Option A is correct because De Morgan’s First Law states that the negation of a conjunction is equivalent to the disjunction of the negations: NOT (A AND B) == (NOT A) OR (NOT B). Option B violates De Morgan’s Law by keeping the AND conjunction. Option C incorrectly inverts both conditions with strict inequalities while retaining the AND operator, failing to account for equality boundaries. Option D is logically invalid.
Medium

ICSOC-8.11.6.4 String Manipulation Operators: Concatenation, 1-Based Indexing, and Substring Search

String Manipulation Operators: Concatenation, 1-Based Indexing, and Substring Search

Scratch provides four specialized green operator blocks dedicated to string parsing, concatenation, and textual analysis: “join () ()”, “letter () of ()”, “length of ()”, and “() contains ()?”. The “join () ()” oval reporter concatenates two input strings together into a single continuous text string without inserting extraneous spaces. Programmers can nest multiple “join” blocks inside one another to construct complex dynamic dialogue strings, formatted score readouts (e.g., join [Score: ] (score)), or composite data keys. The “length of ()” reporter returns the total number of Unicode characters within a string or the number of digits in a scalar number.

String indexing in Scratch is fundamentally 1-based rather than 0-based: executing “letter (1) of (apple)” returns “a”, whereas “letter (5) of (apple)” returns “e”. Requesting an index that is less than 1 or greater than the string’s length returns an empty string (“”) rather than throwing an out-of-bounds error. The hexagonal predicate “() contains ()?” searches whether a target substring exists anywhere within a primary text string, returning true or false. Notably, the “contains” block is case-insensitive, meaning <"Banana" contains "nan"> and <"Banana" contains "NAN"> both evaluate to true. These primitives allow developers to build linear search algorithms, text decoders, and custom cipher routines entirely within block code.

Easy
What is the output of the string operator block [letter (3) of [ROBOT]] in Scratch?
Option A is correct because Scratch uses 1-based indexing for strings and lists. Index 1 is ‘R’, index 2 is ‘O’, and index 3 is ‘B’. Option B is incorrect because ‘O’ is at index 2 (or 4). Option C is incorrect because index 1 is ‘R’. Option D is incorrect because index 5 is ‘T’.
Medium
If a sprite evaluates [join [High ] (join [Score: ] [100])], what text string is produced?
Option A is correct because the inner block [join [Score: ] [100]] produces “Score: 100” (retaining the trailing space after the colon). The outer block concatenates “High ” (which includes a trailing space) with “Score: 100”, producing “High Score: 100”. Option B, C, and D are incorrect because [join] does not strip, omit, or inject extraneous delimiters; it preserves exact literal spacing within arguments.
Tricky
What is reported by the string predicate block [<[Olympiad] contains [lym]?>] and what would it report if the search argument were changed to [LYM]?
Option A is correct because Scratch’s [() contains ()?] reporter performs a case-insensitive substring search across the primary string; since “lym” is present in “Olympiad”, both lowercase “lym” and uppercase “LYM” match and report true. Option B is incorrect because Scratch does not enforce case sensitivity in the [contains] block. Option C is incorrect because substring searching matches contiguous sequences regardless of word boundaries. Option D is incorrect because valid strings never trigger runtime errors in Scratch.
Tricky

ICSOC-8.11.6.5 Advanced Mathematical Functions: Modulo Arithmetic, Rounding Logic, and Scientific Operators

Advanced Mathematical Functions: Modulo Arithmetic, Rounding Logic, and Scientific Operators

For advanced mathematical modeling, physics engines, and procedural geometry, Scratch provides sophisticated functional operator blocks: “() mod ()”, “round ()”, and the versatile “([func] v) of ()” dropdown reporter. The modulo operator, “() mod ()”, calculates the remainder of an integer or floating-point division. In Scratch, the modulo operation adheres to mathematical Euclidean definition (floored modulo), meaning that the result always takes the sign of the divisor. Modulo arithmetic is essential for cyclic algorithms, such as wrapping sprite coordinates around screen boundaries, determining even/odd parity ((n mod 2) = 0), and cycling animation frame sequences.

The “round ()” block rounds a floating-point number to the nearest integer, rounding half-way values upward toward positive infinity (e.g., round 2.5 returns 3, while round -2.5 returns -2). The comprehensive “([func] v) of ()” reporter unlocks fourteen advanced mathematical operations via its dropdown menu, including “abs” (absolute value), “sqrt” (square root), “floor” (largest integer less than or equal to input), “ceiling” (smallest integer greater than or equal to input), trigonometric functions (“sin”, “cos”, “tan”), inverse trigonometric functions (“asin”, “acos”, “atan”), and logarithmic/exponential functions (“ln”, “log”, “e ^”, “10 ^”). Trigonometric functions in Scratch expect input angles in degrees rather than radians, allowing direct compatibility with Scratch’s native sprite rotational angles (0 to 360 degrees).

Easy
What is the result of evaluating the reporter block [(17) mod (5)] in Scratch?
Option A is correct because the modulo operator [() mod ()] computes the remainder after division. 17 divided by 5 equals 3 with a remainder of 2 (since 5 * 3 = 15, and 17 – 15 = 2). Option B is the integer quotient, not the remainder. Option C is the floating-point quotient (17 / 5). Option D is an incorrect remainder value.
Medium
How do the Scratch mathematical blocks [round (4.5)] and [round (-4.5)] evaluate?
Option A is correct because Scratch’s [round ()] function implements JavaScript’s Math.round(), which rounds half-way values upward toward positive infinity. For 4.5, rounding up yields 5. For -4.5, rounding toward positive infinity yields -4 (since -4 is greater than -5). Option B, C, and D reflect misinterpretations of round-to-even (banker’s rounding) or symmetric round-away-from-zero logic.
Tricky
A student building a 3D raycasting engine in Scratch uses [[sin v] of (90)]. What value does this block return, and what angular unit does Scratch require for trigonometric functions?
Option A is correct because all trigonometric operators in Scratch’s [[func v] of ()] block (sin, cos, tan, etc.) natively expect input parameters in degrees (0° to 360°), directly aligning with sprite direction angles; sin(90°) = 1. Option B is incorrect because radians are not used as the native input unit in Scratch’s math blocks. Option C is mathematically incorrect. Option D is incorrect because literals, expressions, and variables are all valid inputs.