GUIDED LAB 03 OF 06 · VERIFIED SCARP
Repair a typed function
टाइप्ड फ़ंक्शन सुधारें
The challenge · अभ्यास
The current square function doubles its input instead of squaring it. Fix the return expression so square(6) prints 36.
वर्तमान square फ़ंक्शन इनपुट को दोगुना करता है, उसका वर्ग नहीं निकालता। return व्यंजक सुधारें ताकि square(6) से 36 प्रिंट हो।
starter.srp
// Lab: repair square so it multiplies the input by itself.
pure funcra square(value: integer) -> integer {
return value + value;
}
print(square(6));
solution.stdout
36
Run and check your attempt locally
Copy starter.srp to attempt.srp in the same lab folder,
edit it, and use the pinned Scarp compiler from the repository root.
Keeping the same folder is important for imports and the bundled _support helper.
scarp verify labs/03-functions/attempt.srp
scarp exec labs/03-functions/attempt.srpCompare the printed output with the fixture shown above. No website execution, uploads or stored answers are involved.
Show hint · संकेत देखें
A square is the input multiplied by itself; keep the function parameter and return type unchanged.
वर्ग का अर्थ संख्या को स्वयं से गुणा करना है। फ़ंक्शन पैरामीटर और return type न बदलें।
Reveal tested solution · सत्यापित हल देखें
// Return the mathematical square, then call the typed function.
pure funcra square(value: integer) -> integer {
return value * value;
}
print(square(6));
value * value evaluates to 36 when value is 6.
value = 6 होने पर value * value का मान 36 होता है।
Reference .srp on GitHub ↗The starter compiles but intentionally does not produce the goal. The reference solution and its output are verified on Linux, macOS and Windows against Scarp v0.0.6-alpha.3. Browse all labs ↗