Boolean Values, Conditional Execution, Loops, Lists and List Processing, Logical and Bitwise Operations Flashcards
What is the difference between = and ==?
= is an assignment operator (assign value to variables)
== is the equality operator (binary operator with left sided binding)
2 == 2.0
True
True or false: comparison operators have higher priority than equality operators
True
What is an if statement known as?
Condition statement/instruction
What is an if statement within an if statement called?
Nested if statement
Explain the difference between if and while
When the condition is met:
- if performs its statements only once
- while repeats the execution as long as the condition evaluates to True
What is an endless loop?
An infinite loop is a sequence of instructions in a program which repeat indefinitely
What is ‘while number:’ equivalent to?
while number != 0:
What is used to exit the loop immediately?
break
What is continue used for?
behaves as if the program has suddenly reached the end of the body; the next turn is started and the condition expression is tested immediately.
What are the two types of loops in python?
for and while
What is and?
a conjunction
(binary operator with lower priority than comparison operators)
What is or?
a disjunction
(binary operator with lower priority than and)
What are logical operators?
AND and OR
What is the unary operator performing a logical negation?
NOT
(same priority are unary +/- (v high))