Chapter 2 Flashcards

(26 cards)

1
Q

What are the steps in the program development cycle?

A

Design the program, write the code, correct syntax errors, test the program, correct logic errors

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

What is an algorithm?

A

A set of well-defined logical steps that must be taken to perform a task

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

What is pseudocode?

A

Informal “fake code” with no syntax rules, not meant to be executed; used to design programs

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

What is a flowchart?

A

A diagram that graphically depicts the steps in a program using symbols connected by arrows

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

What are the three main steps of computer processing?

A

Receive input, perform processing, produce output

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

What does the print() function do?

A

Displays output on the screen

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

What is a string?

A

A sequence of characters used as data

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

What is a string literal?

A

A string appearing in a program’s code, enclosed in quotes

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

What is a comment in Python?

A

An explanatory note beginning with #, ignored by the interpreter

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

What is a variable?

A

A name that represents a value stored in memory

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

What is the assignment operator in Python?

A

The equal sign (=)

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

What is multiple assignment?

A

Assigning values to multiple variables in one statement: x, y, z = 0, 1, 2

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

List the rules for naming variables in Python.

A

Cannot be a keyword, no spaces, must start with a letter or underscore, may use letters/digits/underscores after, case-sensitive

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

How does the input() function work?

A

Displays a prompt, reads keyboard input as a string, and assigns it to a variable

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

How do you convert input to an integer or float?

A

Use int(item) or float(item)

17
Q

What are operands and operators?

A

Operands are values; operators perform operations (e.g., +, -, *, /, //, %, **)

18
Q

What is the difference between / and // in Python?

A

/ performs floating-point division; // performs integer division

19
Q

What does the % operator do?

A

Returns the remainder of a division (modulus)

20
Q

What determines operator precedence in Python?

A

Parentheses > Exponentiation > Multiplication/Division/Modulus > Addition/Subtraction

21
Q

What is string concatenation?

A

Joining strings together using +

22
Q

What are escape sequences?

A

Special characters preceded by \, like \n (newline) or \t (tab)

23
Q

What is an f-string?

A

A string prefixed with f that supports variable placeholders and formatting

24
Q

What are magic numbers?

A

Unexplained numeric values in code (e.g., balance * 0.069)

25
What is a named constant?
A name representing a fixed value (e.g., INTEREST_RATE = 0.069)
26
Why use named constants?
They make code self-explanatory, easier to maintain, and reduce errors