πŸ’» Computer Science: Understanding Basic Operations

πŸ”’ 3.2.3 Arithmetic Operations

Arithmetic operations are like the math you already know β€” adding, subtracting, multiplying, and dividing numbers! These help computers do calculations.

✨ Main Operations

πŸ’‘ Example with clocks: Clocks use β€œmodular arithmetic.” If it’s 11 o’clock and you add 3 hours β†’ it’s 2 o’clock!

(11 + 3) % 12 = 2 ⏰

βš–οΈ 3.2.4 Relational Operations

Relational operations help computers compare values β€” to check if one is bigger, smaller, or equal to another. The answer is always True or False.

OperationMeaningExampleResult
==Equal to5 == 5True βœ…
!=Not equal to5 != 3True βœ…
<Less than2 < 5True βœ…
>Greater than7 > 10False ❌
<=Less than or equal to3 <= 3True βœ…
>=Greater than or equal to6 >= 4True βœ…

πŸ“˜ Example in Python:

if age >= 18:
    print("You can vote!")

🧠 3.2.5 Boolean Operations

Boolean operations help computers make decisions using True and False values. They combine or change conditions to decide what should happen next.

OperatorMeaningExampleResult
NOTTurns True β†’ FalseNOT TrueFalse ❌
ANDTrue if both are True(5>2) AND (3<8)True βœ…
ORTrue if at least one is True(5<2) OR (3<8)True βœ…

πŸ“˜ Example in Python:

if (age >= 18) AND (citizen == True):
    print("You are eligible to vote.")

πŸ” Another example:

if (score > 50) OR (NOT submitted_late):
    print("Pass πŸŽ‰")