LESSON 03 OF 52 · CHAPTER 01
Mutable
var, assignments and compound arithmetic
03-mutable.srp
var count = 2;
bind original = count;
count += 5;
print(count);
count *= 3;
count -= 1;
count /= 4;
print(count);
print(original);
stdout
7
5
2
Write what you expect this program to print. Check prediction for a line-level hint without revealing the answer, or reveal the verified output when ready. This checks displayed text only; it does not run Scarp or save your input.
UNDERSTAND THE CODE
Explanation & practice
What this example teaches
var, assignments and compound arithmetic
Expected behavior
Sequence shown in stdout
Practice: Read the source before looking at the output. Predict the values and their order, then use the pinned compiler to execute this lesson and compare the exact fixture. Identify which operation produces the result.
बदलने वाला मान
var से घोषित मान को बाद में बदला जा सकता है। +=, *=, -= और /= असाइनमेंट के साथ गणना करते हैं।
अभ्यास: हर असाइनमेंट के बाद count का मान लिखें।
Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.
SOURCE-BACKED SELF-CHECK · स्रोत-आधारित अभ्यास
Quick checkpoint / त्वरित अभ्यास
After count is changed several times, what does the immutable original still print?count को कई बार बदलने के बाद immutable original का कौन-सा मान प्रिंट होता है?
Reveal the source-backed answer / सही उत्तर देखें
2 — original captures count when its value is 2. Later changes to count do not change original.2 — original में count का शुरुआती मान 2 रखा जाता है। बाद में count बदलने से original नहीं बदलता।
This question checks understanding of a recorded compiler output. It does not run Scarp in the browser. यह प्रश्न सत्यापित आउटपुट पर आधारित है; ब्राउज़र में Scarp नहीं चलता।
LEARNING PROGRESS
Keep your place
Mark this lesson complete when you are ready.
Only saved in this browser. No account or tracking.
TRY IT LOCALLY
Verify, then execute
Use the pinned compiler from the course root. Keep any imported _support files next to the source.
scarp verify examples/01-basics/03-mutable.srp
scarp exec examples/01-basics/03-mutable.srpThe website does not run code. Read the CLI guide ↗
Pinned compiler: Scarp v0.0.6-alpha.3
· ceff07d9014f. No simulated output.