PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Python · Theory

Built-in exceptions

← All stacks

Theory

66/268

Built-in exceptions

Python ships named errors for common failures. ValueError: int("Asha"). TypeError: 1 + "a". IndexError: list[99]. KeyError: dict missing key. FileNotFoundError: open missing path. ZeroDivisionError: 10/0. Exception is a common parent. Catch the type you expect, not a bare except.

Name five and one cause each. That is the viva. Matching name → cause scores more than reciting the hierarchy.

Built-in exceptions — output — ValueError. int("Asha") is the classic cause.

Diagram
try:  10 / 0
         │ ZeroDivisionError
         ▼
  except → Cannot divide
         │
         ▼
      finally
Exam tip

Five names + one cause each.

Example

# Built-in exceptions
try:
    int("Asha")
except ValueError as e:
    print(type(e).__name__)

Built-in exceptions — output: ValueError. int("Asha") is the classic cause.

Short notes

  • DefValueError / TypeError
  • RuleIndexError / KeyError
  • RememberFileNotFound / ZeroDivision

Questions

1

Explain Built-in exceptions as if you are teaching a junior — definition, then one tiny script.

2

What does the example print, and why?

3

What mistake do freshers make with Built-in exceptions?

Previous← finallyNextFile Handling in Python →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.