Python Interview questions - error handling & exceptions
(Python version 3.9 or later version)
Which of the following Python objects is immutable?
set
dict
list
str
What would be the result of executing the following code?
print(True*2)
TrueTrue
True True
2
Syntax Error
Python Interview Questions
  • Python - Errors & Exceptions
    1. To handle an exception you proceed problematic code with the keyword?
    A) except
    B) while
    C) try

    Answer: try
    2. You proceed code that handles an error with the keyword?
    A) try
    B) except
    C) handle

    Answer: except
    3. Keyword you should proceed problematic code to handle an error?
    A) block
    B) try
    C) except

    Answer: try
    4. Keyword used to define code to execute if an exception isn't raised?
    A) else
    B) elif
    C) except

    Answer: else
    5. Keyword used to define code you want to execute whether an exception is triggered or not?
    A) finally
    B) else
    C) final

    Answer: finally
    6. Class to inherit from when creating custom exceptions?
    A) Except
    B) Exceptions
    C) Exception

    Answer: Exception
  • gk