Lecture 3: Exceptions Flashcards

1
Q

What are exceptions?

A

Things that go wrong within our coding (Errors)

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

What are Runtime Errors? and when do we use them?

A

an error that occurs while the program is running after being successfully compiled, commonly called “bugs” and are often found during the debugging process before the software is released.

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

3 types of errors and their definition?

A

-SyntaxError: you wrote something wrong in the code
-ValueError: the user gave you a sort of “unwanted” type of value–> ex: give you a number when you actually wanted a text
-NameError: when a local or global name is not found

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

We use both: try and except as?

A

ways of testing out user input before something goes wrong

and we can also use else with them

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

There are 2 main ways to print a varible next to a text which are?

A

print (“X is “ , x)
print (f “X is “ {x})
#f string

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

in terms of creating our own functions, we replace print with?

A

return

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

in terms of loops, return has 2 jobs?

A

break you out of a loop and return a value.

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

pass is? and when do we use it?

A

a null statement (does nothing) we generally use it as a placeholder.

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