Control Flow Flashcards
How does logical operators work?
There are two main logical operators ‘and’ & ‘or’ which operate
on boolean values. The ‘and’ operator needs both values to be
True to return a True result. The ‘or’ operator only needs
one value to be True to return a True result.
What is boolean logic?
Boolean logic is the name given to comparison operations whose
result is True or False.
==
!=
>
<
>=
<=
are all comparison operations that result in True or False.
Comparison operators are also known as relational operators
Short hand syntax for if-statement?
(do something) if (condition) else (do something else)
What is the result of:
my_variable = 5 < 6
my_variable = True
Relational expressions always evaluate to a boolean value.
What is the purpose of an if-statement and what is its syntax?
The purpose of an if-statement is to provide a means for a program to perform one action over another ie. to make a decision based on some logical condition.
syntax:
if CONDITION is TRUE:
do something!
otherwise do something else!