Back to Syllabus
Chapter 04AAYU Core - Verified

Conditions and branches

Use if/else to check a computed result and print the matching branch.

This lesson uses the verified core subset and links to a checked-in regression program. Its output is covered by the repository test harness. This does not imply support for features outside the lesson; see known limitations.

What you'll learn

✓Compare values with ==
✓Choose a branch with if/else
✓Use conditions to validate a result
✓Keep failure output visible

Make a result check itself

The loop regression checks whether its computed sum is 45. The combined verification example also checks a Fibonacci result with an if/else branch.

aayu
if a == 6765
    print("TEST PASSED: Fibonacci matches 6765!")
else
    print("TEST FAILED")
end

A program exiting successfully does not prove its answer is right. This explicit branch makes a wrong result visible; the test runner also compares complete expected output.

Try It Yourself! 🚀

Change 6765 to 6764. Run the program and confirm the failure branch is printed. Restore the correct value afterward.