Control Flow Flashcards

1
Q

How does logical operators work?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is boolean logic?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Short hand syntax for if-statement?

A

(do something) if (condition) else (do something else)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the result of:
my_variable = 5 < 6

A

my_variable = True
Relational expressions always evaluate to a boolean value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of an if-statement and what is its syntax?

A

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!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly