CUET Computer Science MCQs Chapter 1 Exception and File Handling in Python

Practice CUET Computer Science MCQs Chapter 1 Exception and File Handling in Python provided below. The MCQ Questions for UG Chapter 1 Exception and File Handling in Python Computer Science with answers and follow the latest CUET/ NCERT and KVS patterns. Refer to more Chapter-wise MCQs for CUET UG Computer Science and also download more latest study material for all subjects

MCQ for UG Computer Science Chapter 1 Exception and File Handling in Python

UG Computer Science students should review the 50 questions and answers to strengthen understanding of core concepts in Chapter 1 Exception and File Handling in Python

Chapter 1 Exception and File Handling in Python MCQ Questions UG Computer Science with Answers

Question. What is an exception in Python?
a) A syntax error
b) A runtime error
c) A logical error
d) A compile-time error

Answer : B

Question. Which of the following file methods directly returns a list where each element is a line from the file?
a) read()
b) readline()
c) readlines()
d) readchar()

Answer : C

Question. What will be the output of the following code?
try:
result = 10 / 0
except ZeroDivisionError:
result = "Infinity"
print(result)
a) 10
b) "Infinity"
c) ZeroDivisionError
d) None

Answer : B

Question. When does the search for an appropriate exception handler occur in the process of exception handling?
a) Before the exception object is created.
b) After an exception is raised but before it is executed.
c) After the exception is executed.
d) Parallelly as the exception object is created.

Answer : B

Question. What does the finally block execute if an exception is raised and not caught?
a) It doesn't execute
b) It executes before the exception is raised
c) It executes after the exception is raised
d) It executes only if the exception is caught

Answer : C

Question. Which of the following steps is NOT part of the exception handling process?
a) Automatically correcting all programming errors without any additional code.
b) Raising an exception when an error occurs.
c) Searching for an exception handler after an exception is raised.
d) Executing the exception handler's code to manage the error.

Answer : A

Question. What is the purpose of the raise statement in Python?
a) To raise an arbitrary exception
b) To terminate the program
c) To catch an exception
d) To ignore an exception

Answer : A

Question. Consider the following python code: def myDiv(x, y): if
y = = 0:
raise ZeroDivisionError
return x/y
What is the output of the following?
n = myDiv(4,0)
print(n)

a) 0.0
b) No output
c) ZeroDivisionError
d) ValueError

Answer : C

Question. What does the "?" pattern represent in RegEx?
a) Zero or more occurrences
b) One or more occurrences
c) Zero or one occurrence
d) Exactly one occurrence

Answer : A

Question. Read the following statements and arrange in correct order.
A. Exception is raised
B. Executes exception
C. Program searches for exception handler
D. Create exception object
E. An error encountered
Choose the correct answer from the options given below:

a) A→B→C→D→E
b) E→D→C→A→B
c) E→D→B→C→A
d) E→D→A→C→B

Answer : D

Question. What does the "(?P<name>...)" construct do in a RegEx pattern?
a) Denotes a positive lookahead
b) Captures a named group
c) Represents a character class
d) Defines a negative lookahead

Answer : B

Question. Which statement is/are true about Exception handling?
i. There can be try block without catch block but vice versa is not possible.
ii. There is no limit on the number of catch, block corresponding to a try block.
iii. The object must be created of a specific class of which the error has occurred otherwise runtime error will occur.
iv. To execute a code with each and every run of program, the code is written in finally block.

a) i and ii, iv
b) Only iii
c) ii and iv Only
d) Only ii

Answer : A

Question. How can you match a word that ends with "py" in RegEx?
a) py$
b) \bpy
c) py\b
d) ^py

Answer : C

Question. In Python code, on encountering a syntax error, the _____________ does not execute the program.
a) Processor
b) Editor
c) Interpreter
d) Converter

Answer : C

Question. How can you handle exceptions in Python?
a) Using if-else statements
b) Using try-except blocks
c) Using switch-case statements
d) Using for loops

Answer : B

Question. What will be the output of the following Python code:
a=5.2
try:
  print(a)
except NameError:
  print("Variable a is not defined")
except ValueError:
  print("The value of a must be an integer")

a) The value of a must be an integer
b) Variable a is not defined
c) 5.2
d) 5

Answer : C

Question. How can you catch multiple exceptions in a single except block?
a) Using a comma-separated list of exceptions
b) Using nested try-except blocks
c) By defining a custom exception
d) Using the catch keyword

Answer : A

Question. Which of the following error will be raised by the given Python code:
randomList = ['a', 2, 3]
for element in randomList:
        print("The element is ", element)
        x = int(element+1)
print("The incremeant of ", element, "is", x)

a) NameError
b) ValueError
c) TypeError
d) IOError

Answer : C

Question. What will happen if an exception is raised but not caught in a Python program?
a) The program will terminate abruptly
b) The program will continue to execute without any impact
c) The program will print an error message and continue
d) The program will prompt the user to handle the exception

Answer : A

Question. What will be the output of the following Python code:
a = [4, 5, 6, 7]
try:
    print ("First element is %d" %(a[2]))
    print ("Fifth element is %d" %(a[5])) 
except:
    print ("Error")

a) Error
b) First element is 6 Error
c) First element is 6
Fifth element is 7
d) First element is 4 Error

Answer : B

Question. Which method is used to replace a pattern in a string using RegEx?
a) replace()
b) substitute()
c) re.replace()
d) sub()

Answer : D

Question. How can you make a RegEx pattern match across multiple lines in Python?
a) re.MULTILINE
b) re.SINGLELINE
c) re.LINEALL
d) re.GLOBAL

Answer : A

Question. Which type of error will be raised by the following Python code:
x = 10
y = 20
if (y > x)
  print("y is greater than x")

a) ValueError
b) TypeError
c) IOError
d) Syntax Error

Answer : D

Question. What is the purpose of the finally block in exception handling?
a) To define a block of code that will be executed if an exception occurs
b) To specify the code to be executed regardless of whether an exception occurs or not
c) To catch and handle specific exceptions
d) To raise a custom exception

Answer : B

Question. Which of the following is not a built-in exceptions in Python?
a) ZeroDivisionError
b) OverFlowError
c) KeyboardInterrupt
d) None of the above

Answer : D

Question. What is the purpose of the assert statement in Python exception handling?
a) To catch and handle exceptions
b) To raise a custom exception
c) To check if a given expression is true, otherwise raise an 'AssertionError'
d) To ignore exceptions

Answer : C

Question. What will be the output of the following Python code:
a = 1
if (a = 2):
  print("value of a is", a)

a) value of a is 2
b) value of a is 1
c) IOError
d) Syntax Error

Answer : D

Question. How can you re-raise an exception in Python?
a) Using the retry statement
b) Using the throw statement
c) Using the raise statement without any arguments
d) Using the rethrow keyword

Answer : C

Question. Consider the following Python code and identify the line number(s) which has some error. Assume that the user wants to print the reverse of the given list:
languages = ['java','python','C++']   #List
for i in range(len(languages),0,-1):  #Line-1
print(Languages[i],end=' ')               #Line-2

a) Line-1
b) Line-2
c) Both Line-1 and Line-2
d) No Error.

Answer : C

Question. Which method is used to check if a pattern is present anywhere in a string using RegEx?
a) search()
b) match()
c) find()
d) locate()

Answer : A

Question. Which of the following statements is used to raise a custom exception in Python?
a) throw
b) raise
c) catch
d) except

Answer : B

Question. What is the output produced by the following lines of code if 1 is passed as input 
a=input()
print("Testing code")
try:
    if a=1:
        print(True)
except:
    print(False)

a) Testing code
True
b) Testing code
False
c) Testing code
SyntaxError
d) SyntaxError

Answer : D

Question. How can you handle exceptions globally in Python?
a) Using the `global_exception_handler()` function
b) By modifying the global exception settings in the `sys` module
c) By using the `global` keyword
d) There is no way to handle exceptions globally

Answer : B

Question. Which character is used to match any whitespace character in RegEx?
a) \s
b) \S
c) \w
d) \W

Answer : A

Question. What does the "re.IGNORECASE" flag do in Python RegEx?
a) Enables case-sensitive mode
b) Disables case-sensitive mode
c) Matches Unicode characters
d) Ignores case

Answer : D

Question. What is the purpose of the else block in exception handling?
a) To handle exceptions
b) To specify code that will be executed if no exceptions are raised
c) To define custom exceptions
d) To skip the execution of the block if an exception occurs

Answer : B

Question. How can you match a word that ends with "ly" in RegEx?
a) \bly$
b) ly\b
c) ^ly
d) \bly\b

Answer : B

Question. What is the purpose of the with statement in Python exception handling?
a) To create a new exception
b) To simplify resource management using context managers
c) To catch and handle exceptions
d) To define a custom exception

Answer : B

Question. In Python, what does the sys.exc_info() function return?
a) The exception type
b) The exception value
c) A tuple containing the exception type, value, and traceback
d) A dictionary containing exception information

Answer : C

Important Practice Resources for Mock Tests for CUET Computer Science

MCQs for Chapter 1 Exception and File Handling in Python Computer Science UG

Students can use these MCQs for Chapter 1 Exception and File Handling in Python to quickly test their knowledge of the chapter. These multiple-choice questions have been designed as per the latest syllabus for UG Computer Science released by CUET. Our expert teachers suggest that you should practice daily and solving these objective questions of Chapter 1 Exception and File Handling in Python to understand the important concepts and better marks in your school tests.

Chapter 1 Exception and File Handling in Python NCERT Based Objective Questions

Our expert teachers have designed these Computer Science MCQs based on the official NCERT book for UG. We have identified all questions from the most important topics that are always asked in exams. After solving these, please compare your choices with our provided answers. For better understanding of Chapter 1 Exception and File Handling in Python, you should also refer to our NCERT solutions for UG Computer Science created by our team.

Online Practice and Revision for Chapter 1 Exception and File Handling in Python Computer Science

To prepare for your exams you should also take the UG Computer Science MCQ Test for this chapter on our website. This will help you improve your speed and accuracy and its also free for you. Regular revision of these Computer Science topics will make you an expert in all important chapters of your course.

Where can I access latest CUET Computer Science MCQs Chapter 1 Exception and File Handling in Python?

You can get most exhaustive CUET Computer Science MCQs Chapter 1 Exception and File Handling in Python for free on StudiesToday.com. These MCQs for UG Computer Science are updated for the 2025-26 academic session as per CUET examination standards.

Are Assertion-Reasoning and Case-Study MCQs included in the Computer Science UG material?

Yes, our CUET Computer Science MCQs Chapter 1 Exception and File Handling in Python include the latest type of questions, such as Assertion-Reasoning and Case-based MCQs. 50% of the CUET paper is now competency-based.

How do practicing Computer Science MCQs help in scoring full marks in UG exams?

By solving our CUET Computer Science MCQs Chapter 1 Exception and File Handling in Python, UG students can improve their accuracy and speed which is important as objective questions provide a chance to secure 100% marks in the Computer Science.

Do you provide answers and explanations for CUET Computer Science MCQs Chapter 1 Exception and File Handling in Python?

Yes, Computer Science MCQs for UG have answer key and brief explanations to help students understand logic behind the correct option as its important for 2026 competency-focused CUET exams.

Can I practice these Computer Science UG MCQs online?

Yes, you can also access online interactive tests for CUET Computer Science MCQs Chapter 1 Exception and File Handling in Python on StudiesToday.com as they provide instant answers and score to help you track your progress in Computer Science.