The Python Tutorial: Chapter 8 - Errors & Exceptions Flashcards
Chapter *;
What is the difference between break and continue?
Continue forces the loop to move to the next iteration, instead of printing the rest of the loop. It keeps you in the loop, whereas break breaks the entire loop.
Break gets you out of the current loop and doesn’t execute anything else, even if one level lower in an if statement
Chapter 8:
What is the difference between else and finally?
Else only executes if the try statement was successful. Finally executes no matter what.
Chapter 6:
What is the purpose of this argument at the end of a file?
if __name__ == “__main__”:
It allows arguments to be passed when it is ran from the command line as a script
Chapter 6:
How do you create a module?
You can simply create a .py file and then call the file name as a module if it is within the same directory. Otherwise, the path needs to be defined.