dcit22a Flashcards

(80 cards)

1
Q

These are the programming errors

A

Bug

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

First Bug

A

Harvard University, 1947

Mark II was having consistent errors

A literal bug – a moth

Disrupted the electronics of the computer

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

Types of Errors

A

Syntax Error
Semantic Error

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

Syntax Error is also called as?

A

Parsing Error

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

Caused by improper format or syntax in Python

A

Syntax Error

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

Usually pointed out by the interpreter during translation

A

Syntax Error

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

Samples of Syntax Error (4)

A

Typographical errors
Improper case
Incorrect indentation
Missing or incorrect arguments or symbols

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

Interpretation Time (Syntax Error)

A

Happens when you ask Python to run your program

The interpreter does not understand a line of code
(It does not understand what you want it to do)

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

Happens when the syntax is correct – no error messages produced – but the program logic is not, thus resulting to incorrect output or result

A

Semantic Error

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

May cause the program to crash

A

Semantic Error

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

Usually more difficult to find and may sometimes need a debugger to find it

A

Semantic Error

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

Runtime (Semantic Error)

A

Happens after the code has been interpreted and the computer executes it

Execution may stop and display an error or exception message

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

Possible Reasons for Runtime Errors (5)

A

Incorrect program logic
Incorrect user input
Lack of error handling code
Network error (necessary resources might be unavailable)
Hardware error

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

The process of finding and correcting errors or bugs in the program code

A

Debugging

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

How to avoid debugging? (3)

A

Understand the problem
Start Small
Keep improving your code

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

Helpful for finding and correcting bugs that are difficult to find

A

Debugger

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

In the IDLE, ___ is the Python Debugger and is part of the standard library

A

pdb

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

Other python IDEs also has _____ debuggers

A

built-in

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

The order of execution of statements is _____, by default – from top to bottom

A

linear

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

The order of executing statements in a program

A

Flow of Control

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

The _____ data type is fundamental to the flow of control

A

Boolean

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

Remember that it has two (2) possible values:

A

True or False

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

Set by relational operators (6):

A

==, ! =, >, <, >=, <=

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

Part of every programming language are statements that can tweak or modify the said order, which allows programmers to (2):

A

Decide whether or not to execute a particular statement (or code block)

Repeatedly perform a particular statement (or code block)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
How do humans make decisions? (4)
Based on experience Based on calculations or predictions Based on other’s suggestions/recommendations Based on gut or feelings
26
Decision-making by computers (3)
Get the current or actual value of something Compare this to a desired value Act accordingly (based on the comparison)
27
Decision Control Structures (5)
Conditional Statement If Statement If... Else Statement Making Multiple Comparisonsa Elif Structure
28
Conditional Statement is also called a?
branch
29
Piece of code that is executed under certain conditions (If the condition is not met, this will not be executed)
Conditional Statement
30
Helps a program to have the ability to react on different states that resulted from computations and/or inputs
Conditional Statement
31
The most basic decision control structure
If Statement
32
Executes a line or block of code if the condition is met – if the Boolean expression returns True
If Statement
33
The general format of an if statement is:
if condition: statement/s
34
the __ indicates the end of the condition
: or colon
35
the code block is _____ with respect to the rest of the code: to clearly identify which part of the code depends on the current condition
indented
36
Used when you want an alternative course of action(s) if the condition in the if statement was not met (The else clause is executed in this case)
If... Else Statement
37
The general format of an if...else statement is:
if condition: statement/s 1 else: statement/s 2
38
Series of statements is also called as?
code block
39
It is necessary when dealing with multiple requirements
Making Multiple Comparisons
40
In programming, logical operators – ___, __, ___ – are combined with relational operators to do multiple comparisons
and, or, not
41
Made up from the combination of else and if
Elif Structure
42
Used when if...else is not enough to handle all possible conditions or courses of actions
Elif Structure
43
The general format of elif structure is:
if condition: statement/s 1 elif condition: statement/s 2 else: statement/s 3
44
You may have more than one elif statement. True or False
True
45
You may or may not have else when you use elif. True or False
True
46
If there are ___________, the interpreter would check all the conditions within those statements – they are treated as individual, unrelated conditions
multiple if statements
47
Using ____ “tells” the interpreter that the conditions from if, the following elif statements, and else are connected and related to each other
elif
48
Handles multi-level decision-making
Nested decision statements
49
Process of making decisions in different levels
Nesting
50
Repetitive statements = ____ statements
loop statements
51
repetition is viewed as a _____
circle
52
Iterative Statements rely on __________ ____________ when to stop looping
relational statements
53
Without them (relational statements), loops would go on forever – ______ _____
infinite loop
54
Python has two primitive kinds of iterative statements:
for loop while loop
55
Each loop has the following (sometimes, only implicitly): (4)
A control variable or loop counter The initial value The loop continuation condition The increment or decrement
56
Statements under this will be executed repeatedly while the condition returns True (Once the condition returns False, the line after the loop will be executed)
While Loop
57
While Loop format:
while condition: statement/s
58
Used for looping sequences – list, string, number range
For Loop
59
For Loop format:
for iterating_var in sequence: statement/s
60
This returns a sequence of numbers
Range Function
61
By default, range function starts at _, and increments by _
starts at 0 increments by 1
62
Range Function does not work on _____ _____ numbers
floating point numbers
63
May be a number or variable with numerical value (3)
range (value) range (start, stop) range (start, stop, step)
64
A loop in which the number of times it is going to execute is known in advance before entering the loop
Definite Loop
65
The number of loops or iterations depend on the user input
Indefinite Loop
66
In python, the _______ function ends with a new line
print ( )
67
Stops the loop even when the looping continuation condition still returns True and executes the statement/s after the loop However, it must be under an ___ statement (which is also within the loop)
Break Statement an If statement
68
Similar to break, it is part of an if statement within a loop
Continue Statement
69
Processing proceeds to the next element in the sequence instead of ending the loop completely
Continue Statement
70
Technically, the element(s) that will meet the condition in the if statement will be skipped in the processing in the loop
Continue Statement
71
Used when a statement is required syntactically but you do not want any code to execute – a null statement
Pass Statement
72
Similar to the continue clause, but executes the code below it (which is also inside the if code block where the pass statement is included)
Pass Statement
73
Useful to place for parts of code that you will put some code, but haven’t written yet – to avoid error (This is because the interpreter ignores the pass statement and continues with the rest of the code)
Pass Statement
74
Executes a code when all the iterations have been completed, and NOT indefinitely terminated by a break statement
Else Statement
75
The program exits the loop only after the else block is executed
Else Statement
76
Seems unnecessary, but may serve as a flag that the loop was finished
Else Statement
77
Allow us to execute a statement or block of code multiple times
Control Structure
78
Meaning the start value is greater than the stop value It is required to have a negative step value
Reverse Range
79
It brings control out of the loop
Break
80
It returns control back to the beginning of the loop
Continue