Chapter 3 cards Flashcards

1
Q

What is an algorithm?

A

A procedure for solving a problem in terms of:
- the actions to execute
- the order in which these actions execute

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

What is program control?

A

It specifies the order in which statements (actions) execute in a program.
Python does this with Python’s control statements

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

A(n) ______________ is a procedure for solving a problem. It specifies the ________ to execute and the _______ in which they execute

A

Algorithm, actions, order

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

What is Pseudocode?

A

An informal language that helps develop algorithms without having to worry about the strict details of Python synthax. Similar to everyday English. Helps you ‘think out’ a program before attempting to write it in a programming language
- Text describes what the program should do
- Convert text to Python with Python equivalent

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

T/F

Pseudocode is a simple programming language

A

False
Pseudocode is not a programming language. It’s an artificial and informal language that helps you develop algorithms

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

Define

Sequential execution

A

Where statements in a program execute in the order in which they’re written

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

Define

Transfer of control

A

A Python statement that enables you to specify that the next statement to execute may be other than the next one in sequence

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

Explain

How is transfer of control achieved?

A

With Python control statements

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

What are the 3 forms of control that all programs be written with?

A
  • Sequential execution
  • Selection statement
  • Iteration statement (repetition)

Python statements execute ‘in sequence’ unless directed otherwise

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

Define

Flowchart

A

A ‘graphical’ representation of an algorithm or a part of one

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

Explain

How to draw a flowchart

A

Draw flowchart using rectangles, diamonds, rounded rectangles and small circles that you connect by arrows called flowlines

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

Why is a flowchart useful?

A

Helps develop and represent algorithms. They show how forms of control operate.

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

What do we use to indicate an action in a flowchart?

A

We use rectangle (or action) symbol

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

What shows the order in which actions are executed in a flowchart?

A

Flowlines

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

What is seen at the beginning of a complete algorithm?

A

A rounded rectangle containing the word Begin

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

What is the last symbol you see in a completed algorithm?

A

A rounded rectangle containing the word End

17
Q

When are rounded rectangles omited in an algorithm?

A

For a part of the algorithm, instead using small circles called connector symbols

18
Q

What is the most important symbol in an algorithm?

A

Decision or diamond symbol which indicates that a decision is to be made, such as in an if statement

19
Q

What are the 3 selection statements that execute code based on a condition (an expression that evaluates to either True or False:

A
  1. If performs an action in a condition is True or skips the action if the condition is False
  2. If ….. else statement performs an action if a condition is True or performs a different action if the condition is False
  3. Ifelif….. else statements perform one of many different actions, depending on the truth or falsity of several conditions
20
Q

Why is the If statement called a single-selection statement?

A

It selects or ignores a single action (or group of actions).

21
Q

Why is the If… else statement called double-selection statement?

A

It selects between two different actions (or groups of actions).

22
Q

Why is the If… elif… else statement called multiple-selection statement?

A

It selects one of many different actions (or groups of actions)

23
Q

What are the 2 keywords Python uses for repetition statements (iteration)?

A

while and for

24
Q

Define the 2 repetition statement types

A
  • while statement repeats an action (or group of actions) as long as a condition remains true
  • for statement repeats an action (or a group of actions) for every item in a sequence of items
25
Q

What are the keywords discussed on this chapter that Python reserbes to implement its features, such as control statements?

A

if
elif
while
for
True
False
None

Note the bold words start with an uppercase letter

26
Q

What is a quick summary of control statements in this chapter?

A
  • You form each Python program by combining as many control statements of each type as you need for the algorithm the program implements
  • With single-entry/single-exit (one way in/one way out) control statements, the exit point of one connects to the entry point of the next (similar to the way a child stacks building blocks – hence, the term control-statement stacking
  • Control-statement nexting also connexts control statements – next chapter
27
Q

You can write all programs usiing three forms of control –_____, _______ and _________

A

Sequential execution
Selection statements
Repetition statements

28
Q

A(n) ________ is a graphical representation of an algorithm

A

Flowchart