Numbers and Booleans - mrprov12/DSPrep GitHub Wiki

Numbers and Booleans

= += -= *= /= **=

      • / // **
        // floor division
        % remainder (mod)
        == finds relation between two booleans, relational operator
        != result type: boool; "not equal to"
        < <= > >=
        and, or ->> bool op used to preform logical conjuction

not:

returns True when op is false orr 0, vice versa

del:

removes item/element at a specified index location from lis, not returned; takes index as arg, deletes itema at index

int:

num w/o decimal, +/-

float:

num with decimal, +/- (always returned by /)

True:

bool(1)

False:

0, None, len() ie. [] or " ", bool(0)

Basic Operators

// floor division

if either is a float, will return a float

% modulus

trial division: see if divides in evenly, common step to find primes and all divisors of

given num

parity: mod 2, whether an integer is even or odd
if either is a float, will return a float

Order of op

PEMDAS, M includes %
if same precedence, left to right

Logical ops

and, or, !
btwise: & = and, |. = or, ~ = not
exclusive or (^) = only when 1 op is true (vs or where bith can be true
not evaluated 1st, then and, or last
bitwise 1st, then logical op
excl or befor or

comparison ops

< > <= >= == !=

⚠️ **GitHub.com Fallback** ⚠️