← Quiz: Reviewing AI Code: all 10 questions
Quiz: Reviewing AI Code · Question 9 of 10
In getdiscount, what should replace except Exception: return 0?
In get_discount, what should replace except Exception: return 0?
- A.except KeyError: return 0, so that real bugs like a None code still raise an error
- B.except: pass
- C.Remove the dictionary
- D.except Exception: return 50
Answer & explanation
Correct answer: except KeyError: return 0, so that real bugs like a None code still raise an error
Catch only the specific error you expect.
Can you get the rest right without peeking?
Take the timed Quiz: Reviewing AI Code quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →