CUET Humanities Exam  >  CUET Humanities Tests  >  Computer Science Practice Tests: CUET Preparation  >  Test: Exception Handling in Python - 2 - CUET Humanities MCQ

Test: Exception Handling in Python - 2 - CUET Humanities MCQ


Test Description

20 Questions MCQ Test Computer Science Practice Tests: CUET Preparation - Test: Exception Handling in Python - 2

Test: Exception Handling in Python - 2 for CUET Humanities 2024 is part of Computer Science Practice Tests: CUET Preparation preparation. The Test: Exception Handling in Python - 2 questions and answers have been prepared according to the CUET Humanities exam syllabus.The Test: Exception Handling in Python - 2 MCQs are made for CUET Humanities 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Exception Handling in Python - 2 below.
Solutions of Test: Exception Handling in Python - 2 questions in English are available as part of our Computer Science Practice Tests: CUET Preparation for CUET Humanities & Test: Exception Handling in Python - 2 solutions in Hindi for Computer Science Practice Tests: CUET Preparation course. Download more important topics, notes, lectures and mock test series for CUET Humanities Exam by signing up for free. Attempt Test: Exception Handling in Python - 2 | 20 questions in 20 minutes | Mock test for CUET Humanities preparation | Free important questions MCQ to study Computer Science Practice Tests: CUET Preparation for CUET Humanities Exam | Download free PDF with solutions
Test: Exception Handling in Python - 2 - Question 1

If a programmer does not follow the rules of Python programming, then what type of errors will he get while executing the program?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 1

There are certain rules to write a program in Python. If a programmer does not follow these rules strictly, syntax errors will occur such as incorrect spellings, punctuation errors and incorrect labels.

Test: Exception Handling in Python - 2 - Question 2

Which of the following errors gets raised when a file specified in a program statement cannot be opened?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 2

An IO error occurs when a file specified in a program statement cannot be opened. A name error occurs when a global or local variable name is not defined. An import error occurs when the requested module definition is not found. A zero division error occurs when the denominator in a division operation is zero. So, option 1 is the correct answer.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Exception Handling in Python - 2 - Question 3

_______ is raised when the system accepts a string instead of an integer value.

Detailed Solution for Test: Exception Handling in Python - 2 - Question 3

A syntax error occurs when a spelling mistake or incorrect label is found in the code. When a string is accepted instead of an integer value, a value error is raised. So, option 3 is the correct answer.

Test: Exception Handling in Python - 2 - Question 4

Which of the following keywords is used to handle exceptions in Python?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 4

The Except keyword is used to handle the exceptions in a Python program. The Try block is used to throw an exception in the program. So, option 2 is the correct answer.

Test: Exception Handling in Python - 2 - Question 5

Which of the following statements is true?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 5

A program behaves abnormally when an exception is raised in the program and the code inside the Try block is not executed properly and the control gets transferred to the Except block. So, option 1 is the correct answer.

Test: Exception Handling in Python - 2 - Question 6

Which of the following statements is/are correct?
I. Exception handlers are designed to separate the main logic of the program from the error detection and correction code.
II. Both user-defined and built-in applications require exception handling.

Detailed Solution for Test: Exception Handling in Python - 2 - Question 6

It is very important to maintain and handle the separate logic of the program from the error detection code and correction code. Exceptions can be handled using exception handlers to tackle built-in and user-defined exceptions. So, option 3 is the correct answer.

Test: Exception Handling in Python - 2 - Question 7

What are the advantages of using exception handling in Python programming?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 7

Exception handling in Python programming is necessary to maintain the normal behavior of the program and to generate the correct output. A program must maintain a separation between the main logic and the error detection and correction code. So, option 3 is the correct answer.

Test: Exception Handling in Python - 2 - Question 8

When will a Finally block be executed in a program?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 8

A program statement written inside the Finally block will always be executed regardless of whether there is an exception or not an exception in the program. So, option 4 is the correct answer.

Test: Exception Handling in Python - 2 - Question 9

When will an Else block be executed in a Python program?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 9

An Except block gets executed to raise an exception in the program. An Else block gets executed when no exception is raised in the program. So, option 2 is the correct answer.

Test: Exception Handling in Python - 2 - Question 10

How many Except blocks can be there in a Python exception handler?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 10

There can be any number of Except blocks in a Python program to raise different type of exceptions. So, option 2 is the correct answer.

Test: Exception Handling in Python - 2 - Question 11

Mr. Rakesh executes a Python program. The program gets executed but generates an unexpected output and behaves abnormally. What is the possible cause for this?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 11

If a program contains spelling mistakes, incorrect labels (syntax errors) or logical errors (adding instead of subtracting), it behaves abnormally while being executed and generates an unexpected output. So, option 3 is the correct answer.

Test: Exception Handling in Python - 2 - Question 12

Which of the following is an incorrect statement?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 12

There is no way other than writing a piece of code to handle exceptions. An exception can be handled usually by writing a code using try and catch block. So, option 1 is the correct answer.

Test: Exception Handling in Python - 2 - Question 13

_______ is raised when a user accidentally hits the Esc or Delete key while executing a program.

Detailed Solution for Test: Exception Handling in Python - 2 - Question 13

When a user accidentally hits the Delete or Esc key, the compiler generates KeyboradInterrupt error while executing the program. A TypeError occurs when a wrong type of variable is defined. A ValueError occurs when a wrong value is assigned to a variable. So, option 2 is the correct answer.

Test: Exception Handling in Python - 2 - Question 14

A program will not be compiled if

Detailed Solution for Test: Exception Handling in Python - 2 - Question 14

An exception in a program is handled using the Try, Except and Finally programs. It is mandatory to place the Finally and Except blocks properly to compile a program in Python. So, option 1 is the correct answer.

Test: Exception Handling in Python - 2 - Question 15

A programmer has written the following code:
a = 5;b = ' C ' ;print(a+b);
What is the error generated by the compiler while executing the above code?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 15

A string type of value cannot be added to an integer type variable. Therefore, a type error occurs while executing this program code. So, option 4 is the correct answer.

Test: Exception Handling in Python - 2 - Question 16

Which type of error will occur while executing the following code?
f = open( abc.txt , 'r');

Detailed Solution for Test: Exception Handling in Python - 2 - Question 16

IOError is raised in a program when the file specified in the program cannot opened. The file named 'abc.txt' is available in the read mode only. So, option 2 is the correct answer.

Test: Exception Handling in Python - 2 - Question 17

Consider the following code:
try num1= 10 num 2 = 0 q = num1/num2 except ZeroDivisionError:print( Division is not possible as num2 is set to 0'') else: print( quotient = q).
Which error will occur on execution of this program?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 17

A ZeroDivisionError will occur while executing the program when 0 value is assigned to the variable representing the denominator in the program. So, option 2 is the correct answer.

Test: Exception Handling in Python - 2 - Question 18

What will be the output of the following code?
try if '1' ! =1:raise some Error else: print (SomeError has not occurred)except someError: print ( someError has executed)

Detailed Solution for Test: Exception Handling in Python - 2 - Question 18

The output of the program will be 'invalid code' as a new exception class must be inherited from the BaseException. There is no such inheritance there. So, option 3 is the correct answer.

Test: Exception Handling in Python - 2 - Question 19

Which type of exception will be thrown by the following code?
A = [12,32,40]
print (A[4])

Detailed Solution for Test: Exception Handling in Python - 2 - Question 19

An Index Error occurs in the program when the index mentioned in the print statement is wrong as there are only three items in the list. So, option 3 is the correct answer.

Test: Exception Handling in Python - 2 - Question 20

Which of the following errors will occur when a module does not exist in the program?

Detailed Solution for Test: Exception Handling in Python - 2 - Question 20

When a module or file does not exist in the program, an Import Error will occur in the program.

28 tests
Information about Test: Exception Handling in Python - 2 Page
In this test you can find the Exam questions for Test: Exception Handling in Python - 2 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Exception Handling in Python - 2, EduRev gives you an ample number of Online tests for practice

Top Courses for CUET Humanities

Download as PDF

Top Courses for CUET Humanities