➕ Operators

Operators: Operators are the code version of the math symbols from school (+, -, >, <) — but LOGICAL operators like "and"/"or" add something school never covered: the power to co

Operators are the code version of the math symbols from school (+, -, >, <) — but LOGICAL operators like "and"/"or" add something school never covered: the power to combine multiple conditions. Ask yourself: why does the difference between "or" and "and" actually matter for a QA engineer? Because writing "server_status == 'UP' or db_status == 'UP'" treats JUST ONE service being up as "everything's ready" — when really both need to be UP, meaning "and" was the correct operator all along. That one-word difference can make your test run against a half-crashed system while reporting "environment ready." Java's && and || follow the exact same logic — only the symbols differ, the reasoning stays identical.

Arrange the steps in the order Python actually evaluates result = 7 + 2 * 3 ** 2 % 5 (which operator runs first?).

3 ** 2 → 9 (exponent has the HIGHEST precedence)

2 * 9 → 18 (multiplication runs left-to-right, after exponent)

18 % 5 → 3 (modulo shares precedence with *, evaluated left-to-right)

7 + 3 → 10 (addition runs LAST)

Java vs Python — Operators

What does the "not in" operator do in Python?

It checks if a value is NOT in a sequence

It removes an element from a list

"not in" checks if a value is absent from a sequence. Equivalent to Java's !list.contains(x).

What does 5 not in [1, 2, 3, 4] return in Python?

The 'not in' operator returns True if the element is not present in the sequence. Since 5 is not in the list, the result is True.

What happens if you assign x = 5 (int) and then x = "hello" (string) to the same variable in Python?