Conditions Flashcards

1
Q

Boolean expression:

A

The special value False:
The special value None (more about that in the next chapter)
Every numerical value that is zero, e.g., 0 and 0.0
Every empty sequence, e.g., an empty string (“”)
Every empty “mapping”, e.g., an empty dictionary (dictionaries follow in a later chapter)
Any function or method call that returns one of these listed values (this includes functions that return nothing)

Every other value is interpreted as True.

Any expression that is evaluated as True or False is called a “boolean expression”.

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

comparison:

A
<    less than
<=   less than or equal to
==   equal to
>=   equal to or greater than
>    greater than
!=   not equal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

‘in’ & ‘not in ’ operator

A

A string is a collection of characters. You can test if a particular character or a sequence of characters is part of the string using the in operator. The opposite of the in operator is the not in operator, which gives True when in gives False, and which gives False when in gives True.

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

logical operators

A

“and” and “or” are placed between two boolean expressions.

When “and” is between two boolean expressions, the result is True if and only if both expressions evaluate to True; otherwise it is False.

When “or” is between two boolean expressions, the result is True when one or both of the expressions evaluate to True; it is only False if both expressions evaluate to False.

“not” is placed in front of a boolean expression to switch it from True to False or vice versa.

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