Python Programming (2180711) MCQs

MCQs of Testing, Debugging, Exceptions and Assertions

Showing 11 to 18 out of 18 Questions
11.
What will be the output of the following Python code?
g = (i for i in range(5))
type(g)
(a) class <’loop’>
(b) class <‘iteration’>
(c) class <’range’>
(d) class <’generator’>
Answer:

Option (d)

12.
What will be the output of the following Python code?
int('65.43')
(a) ImportError
(b) ValueError
(c) TypeError
(d) NameError
Answer:

Option (b)

13.
Which of the following statements is true?
(a) The standard exceptions are automatically imported into Python programs
(b) All raised standard exceptions must be handled in Python
(c) When there is a deviation from the rules of a programming language, a semantic error is thrown
(d) If any exception is thrown in try block, else block is executed
Answer:

Option (a)

14.
Which of the following is not a standard exception in Python?
(a) NameError
(b) IOError
(c) AssignmentError
(d) ValueError
Answer:

Option (c)

15.
Syntax errors are also known as parsing errors.
(a) TRUE
(b) FALSE
Answer:

Option (a)

16.
An exception is ____________
(a) an object
(b) a special function
(c) a standard module
(d) a module
Answer:

Option (a)

17.
_______________________ exceptions are raised as a result of an error in opening a particular file.
(a) ValueError
(b) TypeError
(c) ImportError
(d) IOError
Answer:

Option (d)

18.
Which of the following blocks will be executed whether an exception is thrown or not?
(a) except
(b) else
(c) finally
(d) assert
Answer:

Option (c)

Showing 11 to 18 out of 18 Questions