Flow Of Control Flashcards

1
Q

Logical operators or logical connectives

A

Not, and, or, ==

2 possible Boolean values, True or False

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

Logical equivalence

P == q

A

==

Will be True only when both have the same truth value. (Both True ir both false)

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

Logical “and”

P and q

A

True only when both are True

P and q

True only when p is true and q is true.

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

Logical “or”

P or q

A

True only when either one is True

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

!= means what?

A

Not equal

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

Logical negation

Not True

A

Not p

True when p is False, and False when p is True

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

If statements

A

Always begins with the keyword if.

Followed by Boolean expression called the if-condition

Followed by a colon (:)

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

If-statement header

A

Everything from the if statement to the :

Before_block 
If cond:
     True_block
Else:
    False_block
After_block
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If/elif - statements

A

A generalized if-statement with more than one condition.

Elif = else if

If ..... :
     If_block
Elif ... :
    Elif_block
Else:
    Else_block
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

For-loops

A

A given block of code repeated some specified number of times.

For (loop variable) (keyword) (range):

For i in range(10):

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

While-loops

A

While-loop header

While (while loop condition)
The condition is boolean and always returns a True or False

If condition true, then executes while-loop body, if false executes what is after body.

First line is initialization statement ue i = 0
Incremental, i = i + 1

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

While-loop flow

A

Initializer_block
While cond:
Body_block
After_block

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

How do you exit a loop?

A

Break statement

Break # causes to jump out of the loop

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

Boolean logic

A

Boolean logic is all about manipulating so-called truth values.

Written True or False

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