week 5- advanced branching Flashcards
diagram code should include
input, output, branches + conditions, and other processes
code style
readability, consistent naming conventions and file header comments
basic ranges
use elif statements to check different conditions and use and/or
should you compare floating point numbers with relational operators?
no
can relational operators compare strings?
yes, only == or != or you can use to compare lengths
how are strings compared
each number is converted to it’s ASCII value and characters are compared in order
how are lists/tuples compared
with priority to the 1st element to determine T or F
how are dictionaries compared
by key
membership operators
in and not in, checks for presence of specific values in container and returns T or F
substring
specific part of smaller string
‘abc’ in ‘yakabc’ returns
true
identity operators
is and is not, checks if operands reference the same object in memory
object identity
memory address of object
id(x)
checks object identity of x
precedence rule
pemdas, relational operators, not, and, or