Writing and Troubleshooting Python Scripts Flashcards
1
Q
how do you call the main function
A
if __name__ == “__main__”:
2
Q
why .pyc extension is needed
A
python code is still compiles byte level code upon execution for speed
3
Q
what is a global variable
A
variables that are defined to be available everywhere in the script
4
Q
variable passed in to functions have which scope
A
local scope
5
Q
what is Python’s way to handle exceptions
A
try/except statements
6
Q
exceptions are
A
errors detected during execution
7
Q
why do you want to handle exceptions properly
A
it allows you to catch them and possibly execute a piece of code on an event of an error (like notify or reboot a device)
8
Q
what is IndexError
A
index value does not exist when reading a list