- Which keyword is used to handle exceptions in Python?
View Answer
Correct answer: A — try
- What will be printed?
1 try: 2 print(10/0) 3 except ZeroDivisionError: 4 print("Eduinq Error") View Answer
Correct answer: A — Eduinq Error
- Which of the following is used to raise exception manually?
View Answer
Correct answer: B — raise
- What is the output of print(type(Exception))?
View Answer
Correct answer: A — <class 'type'>
- Which of the following is used to execute code regardless of exception?
View Answer
Correct answer: A — finally
- What will be printed?
1 try: 2 x = int("Eduinq") 3 except ValueError: 4 print("Error") View Answer
Correct answer: A — Error
- Which of the following is base class for all exceptions?
View Answer
Correct answer: B — BaseException
- What is the output of print(isinstance(ZeroDivisionError(),Exception))?
View Answer
Correct answer: A — True
- Which of the following is used to catch multiple exceptions?
View Answer
Correct answer: A — except (Error1,Error2)
- What will be printed?
1 try: 2 print(1/0) 3 except (ZeroDivisionError,ValueError): 4 print("Eduinq Exception") View Answer
Correct answer: A — Eduinq Exception
- Which of the following is used to define custom exception?
View Answer
Correct answer: A — class MyError(Exception)
- What is the output of print(issubclass(ZeroDivisionError,Exception))?
View Answer
Correct answer: A — True
- Which of the following is used to catch all exceptions?
View Answer
Correct answer: C — Both A and B
- What will be printed?
1 try: 2 print("Eduinq") 3 finally: 4 print("Python") View Answer
Correct answer: A — Eduinq Python
- Which of the following is used to re raise exception?
View Answer
Correct answer: A — raise
- What is the output of print(isinstance(Exception(),BaseException))?
View Answer
Correct answer: A — True
- Which of the following is used to catch exception object?
View Answer
Correct answer: A — except Exception as e
- What will be printed?
1 try: 2 raise ValueError("Eduinq") 3 except ValueError as e: 4 print(e) View Answer
Correct answer: A — Eduinq
- Which of the following is used to catch specific exception?
View Answer
Correct answer: A — except ValueError:
- What is the output of print(issubclass(ValueError,BaseException))?
View Answer
Correct answer: A — True
- Which of the following is used to define assertion error?
View Answer
Correct answer: C — Both A and B
- What will be printed?
1 try: 2 assert 2>3 3 except AssertionError: 4 print("Eduinq Assertion") View Answer
Correct answer: A — Eduinq Assertion
- Which of the following is used to catch IOError?
View Answer
Correct answer: C — Both A and B
- What is the output of print(isinstance(IOError(),OSError))?
View Answer
Correct answer: A — True
- Which of the following is used to catch KeyboardInterrupt?
View Answer
Correct answer: A — except KeyboardInterrupt:
- What will be printed?
1 try: 2 raise KeyboardInterrupt 3 except KeyboardInterrupt: 4 print("Eduinq Interrupt") View Answer
Correct answer: A — Eduinq Interrupt
- Which of the following is used to catch IndexError?
View Answer
Correct answer: A — except IndexError:
- What is the output of print(isinstance(IndexError(),LookupError))?
View Answer
Correct answer: A — True
- Which of the following is used to catch KeyError?
View Answer
Correct answer: A — except KeyError:
- What will be printed?
1 try: 2 d = {"Eduinq":1} 3 print(d["Python"]) 4 except KeyError: 5 print("Key Error") View Answer
Correct answer: A — Key Error
- Which of the following is used to catch TypeError?
View Answer
Correct answer: A — except TypeError:
- What is the output of print(isinstance(TypeError(),Exception))?
View Answer
Correct answer: A — True
- Which of the following is used to catch AttributeError?
View Answer
Correct answer: A — except AttributeError:
- What will be printed?
1 try: 2 x = 10 3 x.append(5) 4 except AttributeError: 5 print("Eduinq Attribute Error") View Answer
Correct answer: A — Eduinq Attribute Error
- Which of the following is used to catch ImportError?
View Answer
Correct answer: A — except ImportError:
- What is the output of print(isinstance(ImportError(),Exception))?
View Answer
Correct answer: A — True
- Which of the following is used to catch RuntimeError?
View Answer
Correct answer: A — except RuntimeError:
- What will be printed?
1 try: 2 raise RuntimeError("Eduinq Runtime") 3 except RuntimeError as e: 4 print(e) View Answer
Correct answer: A — Eduinq Runtime
- Which of the following is used to catch MemoryError?
View Answer
Correct answer: A — except MemoryError:
- What will be printed?
1 try: 2 a = [1]*1000000000 3 except MemoryError: 4 print("Eduinq Memory Error") View Answer
Correct answer: A — Eduinq Memory Error
- Which of the following is used to catch StopIteration?
View Answer
Correct answer: A — except StopIteration:
- What is the output of print(isinstance(StopIteration(),Exception))?
View Answer
Correct answer: A — True
- Which of the following is used to catch EOFError?
View Answer
Correct answer: A — except EOFError:
- What will be printed?
1 try: 2 raise EOFError 3 except EOFError: 4 print("Eduinq EOF") View Answer
Correct answer: A — Eduinq EOF
- Which of the following is used to catch FloatingPointError?
View Answer
Correct answer: A — except FloatingPointError:
- What is the output of print(isinstance(FloatingPointError(),ArithmeticError))?
View Answer
Correct answer: A — True
- Which of the following is used to catch OverflowError?
View Answer
Correct answer: A — except OverflowError:
- What will be printed?
1 try: 2 import math 3 print(math.exp(1000)) 4 except OverflowError: 5 print("Eduinq Overflow") View Answer
Correct answer: A — Eduinq Overflow
- Which of the following is used to catch ZeroDivisionError?
View Answer
Correct answer: A — except ZeroDivisionError:
- What will be printed?
1 try: 2 print(1/0) 3 except ZeroDivisionError: 4 print("Eduinq Division Error") View Answer
Correct answer: A — Eduinq Division Error