dcit22a Flashcards
These are the programming errors
Bug
First Bug
Harvard University, 1947
Mark II was having consistent errors
A literal bug – a moth
Disrupted the electronics of the computer
Types of Errors
Syntax Error
Semantic Error
Syntax Error is also called as?
Parsing Error
Caused by improper format or syntax in Python
Syntax Error
Usually pointed out by the interpreter during translation
Syntax Error
Samples of Syntax Error (4)
Typographical errors
Improper case
Incorrect indentation
Missing or incorrect arguments or symbols
Interpretation Time (Syntax Error)
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)
Happens when the syntax is correct – no error messages produced – but the program logic is not, thus resulting to incorrect output or result
Semantic Error
May cause the program to crash
Semantic Error
Usually more difficult to find and may sometimes need a debugger to find it
Semantic Error
Runtime (Semantic Error)
Happens after the code has been interpreted and the computer executes it
Execution may stop and display an error or exception message
Possible Reasons for Runtime Errors (5)
Incorrect program logic
Incorrect user input
Lack of error handling code
Network error (necessary resources might be unavailable)
Hardware error
The process of finding and correcting errors or bugs in the program code
Debugging
How to avoid debugging? (3)
Understand the problem
Start Small
Keep improving your code
Helpful for finding and correcting bugs that are difficult to find
Debugger
In the IDLE, ___ is the Python Debugger and is part of the standard library
pdb
Other python IDEs also has _____ debuggers
built-in
The order of execution of statements is _____, by default – from top to bottom
linear
The order of executing statements in a program
Flow of Control
The _____ data type is fundamental to the flow of control
Boolean
Remember that it has two (2) possible values:
True or False
Set by relational operators (6):
==, ! =, >, <, >=, <=
Part of every programming language are statements that can tweak or modify the said order, which allows programmers to (2):
Decide whether or not to execute a particular statement (or code block)
Repeatedly perform a particular statement (or code block)
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
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)
Decision Control Structures (5)
Conditional Statement
If Statement
If… Else Statement
Making Multiple Comparisonsa
Elif Structure
Conditional Statement is also called a?
branch
Piece of code that is executed under certain conditions (If the condition is not met, this will not be executed)
Conditional Statement
Helps a program to have the ability to react on different states that resulted from computations and/or inputs
Conditional Statement
The most basic decision control structure
If Statement
Executes a line or block of code if the condition is met – if the Boolean expression returns True
If Statement