Lecture 3: Exceptions Flashcards
What are exceptions?
Things that go wrong within our coding (Errors)
What are Runtime Errors? and when do we use them?
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.
3 types of errors and their definition?
-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
We use both: try and except as?
ways of testing out user input before something goes wrong
and we can also use else with them
There are 2 main ways to print a varible next to a text which are?
print (“X is “ , x)
print (f “X is “ {x})
#f string
in terms of creating our own functions, we replace print with?
return
in terms of loops, return has 2 jobs?
break you out of a loop and return a value.
pass is? and when do we use it?
a null statement (does nothing) we generally use it as a placeholder.