LESSON 05 OF 52 · CHAPTER 01
Booleans
Comparisons, boolean logic and short-circuiting
05-booleans.srp
// Boolean values, checked comparisons, and readable short-circuit logic.
var ready = false;
bind score = 42;
ready = score >= 40 and score < 100;
print(ready);
print(not ready);
print("Scarp" == "Scarp");
print(false and 1 / 0 == 0);
stdout
true
false
true
false
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
Comparisons, boolean logic and short-circuiting
Expected behavior
true, false, true, false
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.
बूलियन और तुलना
true और false शर्तों के मान हैं। and, or और not का उपयोग होता है। शॉर्ट-सर्किट में अनावश्यक दूसरा भाग नहीं जाँचा जाता।
अभ्यास: false and ... वाले भाग में भाग-शून्य की गणना क्यों नहीं होती?
Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.
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/05-booleans.srp
scarp exec examples/01-basics/05-booleans.srpThe website does not run code. Read the CLI guide ↗
Pinned compiler: Scarp v0.0.6-alpha.3
· ceff07d9014f. No simulated output.