Ch. 5 Flashcards
= vs ==?
= assigns, == means equals
!=?
Not equal
What does “and” do when checking for conditions?
Will check two conditions simultaneously (both must be satisfied for true)
What does “or” do when checking for conditions?
Will check two conditions simultaneously (only one must be satisfied for true)
How do you check if a value is in a list?
Use “in”
Example: value in list_name
will say true or false
How do you check if a value is not in a list?
Use “not in”
Example: if variable not in list_name
A boolean value is either?
True or False
For if statements, how do you apply indentation?
Same as for loops! Must indent after the if statement if you want that line of code to be associated with it.
The else block is a catch all statement, what does that mean?
It matches any condition that wasn’t matched by a specific if or elif test. ( be careful though because that can sometimes include bad or invalid data)
When applying .lower() what happens?
It returns a new string (lowercase), but does not modify the original
Are strings mutable or immutable?
immutable
Empty lists are boolean ___. Not empty are boolean ___.
False, True
How do lists cast to boolean, strings, and integers?
empty list, strings and zero cast to false, non empty lists, strings and numbers cast to true