easy +8 pts

Invariant checker

Build a small function that ensures a numeric invariant holds and reports violations clearly.

Write a function named `check_invariant(a, b, c)` that accepts three numbers and returns `True` if the equation `a == b + c` holds, otherwise `False`. The function must handle integers and floats as inputs. No type checking is needed; numbers are guaranteed to be numeric.

Constraints

Inputs are numbers (int or float). The function should return a boolean. No imports are needed.

Example

>>> check_invariant(5, 2, 3)
True
>>> check_invariant(5, 2, 2)
False
>>> check_invariant(0.1, 0.05, 0.05)
True
>>> check_invariant(-1, 1, -2)
True
8 points ~10 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Think about the exact equality you need to test.
The result should be a boolean, not a string or number.
Use the comparison operator `==` directly.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.