Writing and Troubleshooting Python Scripts Flashcards

1
Q

how do you call the main function

A

if __name__ == “__main__”:

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

why .pyc extension is needed

A

python code is still compiles byte level code upon execution for speed

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

what is a global variable

A

variables that are defined to be available everywhere in the script

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

variable passed in to functions have which scope

A

local scope

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

what is Python’s way to handle exceptions

A

try/except statements

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

exceptions are

A

errors detected during execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)

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

what is IndexError

A

index value does not exist when reading a list

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