🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Exceptions and Files: questions with answers

15 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Which block ALWAYS runs, error or not?
  2. Q2. What error does int("12a") raise?
  3. Q3. What does opening an existing file with mode "w" do?
  4. Q4. What does this print? (code)
  5. Q5. Why use with open(...) as f:?
  6. Q6. What does this print? (code)
  7. Q7. What does this print? (code)
  8. Q8. What does this print? (code)
  9. Q9. Which mode adds to the end of an existing file?
  10. Q10. What does raise ValueError("bad age") do?
  11. Q11. What does this print? (code)
  12. Q12. What does this print? (code)
  13. Q13. Why is a bare except: (with no exception type) a bad idea?
  14. Q14. When reading a file line by line, why do we often call line.strip()?
  15. Q15. What does json.load(f) give you for a file containing {"name": "Asha", "cgpa": 8.7}?