1/53
Looks like no tags are added yet.
What are the three main types of errors in coding?
Syntax errors, run-time errors, and logic errors.
What is a syntax error?
Using incorrect syntax that usually prevents the code from running.
How can syntax errors typically be identified?
Most code editors will catch syntax errors before the code runs.
What is a run-time error?
An error that occurs while the program is running, often referred to as an exception.
Give an example of a run-time error.
Attempting to divide by zero or accessing an index out of range in a list.
What is a logic error?
A mistake in how the code works that produces incorrect output despite the code running.
Why are logic errors considered the toughest to deal with?
They often manifest far from the actual mistake in the code.
What is the purpose of the try-except statement in Python?
To handle run-time errors without crashing the program.
What is the basic structure of a try-except statement?
try: except
What happens if there is no exception in a try-except block?
The code following the try-except block executes normally.
What is a TypeError?
An error that occurs when trying to perform an operation on the wrong type of variable.
What is an IndexError?
An error that occurs when trying to access an element out of range of a list.
What is a ZeroDivisionError?
An error that occurs when attempting to divide by zero.
What is a NameError?
An error that occurs when trying to access a variable that does not exist.
What historical event popularized the term 'bug' in computing?
Grace Hopper found a moth causing a malfunction in the Mark II computer in 1947.
What is the debugging process for inexperienced programmers?
Find something that doesn't work, change something randomly, and check if it fixed the issue.
What is the significance of catching errors with try-except statements?
It allows recovery from errors and provides more information about what went wrong.
What is an example of a logic error due to a typo?
Misspelling a variable name or forgetting to indent a line of code.
What can cause a run-time error related to memory?
Creating an infinite loop that continuously grows a list until memory is exhausted.
What should you do if a run-time error occurs?
Use a try-except statement to handle the error gracefully.
What is the role of the 'except' clause in a try-except statement?
To define the code that runs if an exception of the specified type occurs.
What is a common practice when writing code to prevent crashes?
Implementing try-except statements to catch potential run-time errors.
What does it mean to handle bugs in programming?
Identifying and fixing problems in the code that cause incorrect behavior.
What is a common outcome of logic errors?
The code runs but produces incorrect or unexpected output.
How can better programmers differ from inexperienced ones in error handling?
They tend to make fewer errors and can find and fix errors more quickly.
What does the term 'exception' refer to in programming?
An error that occurs during the execution of a program.
What is the first step in the debugging process?
Identifying something in the code that does not work as intended.
What does the acronym DRIFT stand for in debugging?
Discover, Reproduce, Isolate, Fix, Test
What is the first step in the DRIFT debugging process?
Discover: Find a repeatable problem
What is the purpose of creating a test case in debugging?
To reliably reproduce the problem
What should you do after isolating the bug in your code?
Fix the bug and then test to ensure it is resolved
What is an interactive debugger?
A tool in code editors that helps you debug your code without fixing the bugs automatically
Name three code editors that include a debugger.
VS Code, Spyder, and PyCharm
What is the significance of running code in 'debug mode'?
It allows you to debug the program with additional information but runs less efficiently
What is a breakpoint in debugging?
A marker that pauses code execution at a specific line
What does the 'Step-into' function do in a debugger?
Executes the next line of code and stops inside a function if there is a function call
What is the Call Stack in debugging?
A list of functions that have been called, showing the order of execution
What is the purpose of the Variable Explorer in a debugger?
To view current variables and their values during execution
What should you do if you don't have a debugger available?
Use print statements to output values at various points in the code
What is the purpose of using assert statements in debugging?
To perform sanity checks on parts of your code, ensuring valid inputs and outputs
What happens if an assertion fails in Python?
An AssertionError exception is raised, stopping the program
How can talking to a duck help in debugging?
Explaining your program line-by-line can help identify discrepancies in expected behavior
What is the final step in the DRIFT process?
Consider whether the same error might occur elsewhere and fix it if necessary
How can debugging principles apply outside of programming?
They can be used to systematically solve problems in other areas, like mechanical issues
What is the importance of testing after fixing a bug?
To ensure the bug is resolved and that no other parts of the code were broken
What does the 'Continue/Run' function do in a debugger?
Runs the code until a breakpoint is encountered
What is the difference between 'Step' and 'Step-over' in debugging?
'Step' executes the next line, while 'Step-over' executes the next line and returns normally if it's a function call
What does it mean to isolate a bug?
To narrow down the location in the code where the issue is occurring
What is a common practice to identify where a bug is occurring?
Setting breakpoints close to where you suspect the issue lies
What should you do if you find a line of code causing difficulty?
Step into the line(s) of code to investigate further
What is the significance of confirming user input in a program?
To ensure that the data being processed is valid and expected
What is the role of interpolation in debugging physical properties?
To estimate values between known data points
What is a common debugging task flow in programming?
Read in data, perform calculations, and display results
What should you consider after fixing a bug?
Whether similar issues might exist in other parts of the code