Week 4 Chapter 5 Flashcards
Why is the modulus operator useful?
Can be used to see if one number is divisible by another.
Can extract right most digit/s from a number
What is a Boolean expression?
True or false expression
What data type are booleans?
Belong to bool and are not strings
What is the == ?
Relational operator
What are the three logical operators?
And, or, not
What do conditional statements do?
Check condition then execute accordingly
What is the Boolean expression after an if called ?
Condition
A header followed by a statement is referred to as what?
Compound statements
What does the pass statement do?
Does nothing at that part
What is an example of alternative if execution?
If and else statements
The alternatives in an alternative execution are called what?
Branches
What is a way to express more than two branches in a computation?
Through a chained conditional with an elif statement
In a chained conditional, since elif is required is else required?
Optional but must appear at the end
In chained conditionals what order are branches checked in and what happens when one is true?
Top to bottom and if one is true then it stops right there
What are the cons of nested conditionals?
Difficult to read very quickly, good idea to avoid them
What are nested conditionals?
Conditionals nested in a branch
Is it legal for a function to call itself?
Yes
Is it legal for a function to call another function?
Yes
A function that calls it self is ____and the process is called _____
Recursive recursion
What is the modulus operator?
Modulus operator works on integers and yields the remainder when first operand is divided by the second.