Arithmetic operations are like the math you already know β adding, subtracting, multiplying, and dividing numbers! These help computers do calculations.
π‘ Example with clocks: Clocks use βmodular arithmetic.β If itβs 11 oβclock and you add 3 hours β itβs 2 oβclock!
Relational operations help computers compare values β to check if one is bigger, smaller, or equal to another. The answer is always True or False.
Operation | Meaning | Example | Result |
---|---|---|---|
== | Equal to | 5 == 5 | True β |
!= | Not equal to | 5 != 3 | True β |
< | Less than | 2 < 5 | True β |
> | Greater than | 7 > 10 | False β |
<= | Less than or equal to | 3 <= 3 | True β |
>= | Greater than or equal to | 6 >= 4 | True β |
π Example in Python:
Boolean operations help computers make decisions using True and False values. They combine or change conditions to decide what should happen next.
Operator | Meaning | Example | Result |
---|---|---|---|
NOT | Turns True β False | NOT True | False β |
AND | True if both are True | (5>2) AND (3<8) | True β |
OR | True if at least one is True | (5<2) OR (3<8) | True β |
π Example in Python:
π Another example: