programming help
am i right wiht D?
@extrinix can u just check this last one
`try/except` works by seeing if an entire group of code can be ran, and if not, gives an `exception` of which allows the programmer to either continue with the code or stop the code. So that's the incorrect answer.
Can you explain why it makes sense?
basically i'm checking whether the denominator is zero before performing the division, which prevents the errors from happening
is that right
Ah I read your prompt wrong actually. Yeah, it'd be what you chose originally. A divide by zero error would occur, which is what you need to catch before it breaks your program, apologies.
do/while: this is a loop and does not handle exceptions. for/while: are loop structures, not exception handling mechanisms. They control repetitive execution of code, but they don’t handle errors. If division by zero occurs inside a loop, the program will still crash unless it's caught by a try/except block While if/else can be used to check conditions like whether a denominator is zero, it cannot catch runtime exceptions like a division by zero error that occurs after evaluating the condition So, only try/except properly catches and handles runtime errors like division by zero
thank you
Join our real-time social learning platform and learn together with your friends!