HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Quizzes
  2. /A program has two exception classes of its own, one inheriting from the other. What does the program print?
Python ProgrammingMediumHigh School (11–12)Python Essentials › Errors and ExceptionsClass 12 BoardPCAP (Python Institute)
+1 more exams
A-Level
A-LevelPCAP (Python Institute)
StemPy LabCreated by StemPy Lab

A program has two exception classes of its own, one inheriting from the other. class AppError(Exception): pass class SaveError(AppError): pass def save(n): if n < 0: raise SaveError("negative") return n for n in (2, -1): try: print(save(n), end=" ") except AppError as e: print(type(e).__name__, e) except SaveError: print("save") What does the program print?

Log in to save
← All Quizzes
← A module calc.py and the program main.py sit in the same folder. The program imports the module inside a function. calc.py: main.py: What does main.py print?A class checks its argument with assert in its constructor. What does the program print? →
More onPython Essentials › Errors and Exceptions

Discussion (0)

Log in to join the discussion.

Loading…

More questions on this topic

  1. A function adds results to a list that it is given. Part way through, one of the results fails…Hard
  2. One function calls another. The inner one reads past the end of a list, and neither function has a…Medium
  3. A function reads from a box, which may be a dictionary, a list or a tuple. Its first except names…Hard
  4. A function raises an error when it is given an empty list. Three calls are made inside one try…Medium
  5. A program removes names from a list. One of the names is not in the list. What does the program…Medium
All questions on this topic →

Problems on this topic

  1. Say which error each line gives, before you run it.Easy
  2. The data reader below reports each bad line with a message…Medium
  3. For each job, say whether you would look before you leap (an if) or try and catch (try and except)…Easy
  4. Write a function percent(part, total) that gives part / total * 100…Medium
All problems on this topic →