Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Ready for exam

Rating
-
Sold
-
Pages
13
Uploaded on
11-03-2026
Written in
2025/2026

This document is helpful for those who study class 12 computer science. They have to read long paragraphs to understand but this one will help you to understand the concepts in easy way and it helps you to get ready and prepare for exams easily and quickly

Show more Read less
Institution
Course

Content preview

Chapter 1 - Exception Handling
Types of Error
S.No Name of the Error Explanation
1 Syntax Error (or) Compile  Detected before program runs.
Time Error (or) Parsing  When grammatical rules are not followed in syntax.
Error
2 Runtime Error(Exception)  It is detected during program executes.

3 Logical Error  Raised when a specified file cannot be opened.

Built-in Exceptions
S.No Name of the Exception Explanation
1 SyntaxError Raised due to error in the code’s syntax.
2 ValueError Raised when a method receives correct data types.
3 IOError Raised when a specified file cannot be opened.
4 KeyboardInterrupt Raised when the user presses keys (like Esc) that
interrupt program flow.
5 ImportError Raised when a module cannot be found.
6 ZeroDivisionError Raised when dividing number by zero.
7 EOFError Raised when input() reaches the end of a file without
reading data.
8 IndexError Raised when an index is out of range in a sequence.
9 NameError Raised when a variable name is not defined.
10 IndentationError Raised due to incorrect indentation in the code.
11 TypeError Raised when an operator gets a value of the wrong data
types.
12 OverflowError Raised when the result of a calculation exceeds the
maximum limit for numeric types.

Raise and Assert Statement with syntax and example.
Statement Syntax Explanation
raise raise ExceptionName("Optional  Throws an exception manually.
error message")  Example: raise Exception("OOPS: An
Exception has occurred")
assert assert Expression, "Error  It is tests an expression. If the expression
message" is False, it raises an AssertionError.
 Example:
a=4
b=int(input())
assert b!=0

try-except-else-finally with Syntax and Example
try block Code where exceptions might occur.
except block Handles specific exceptions.
else block Executes if no exception is raised.
finally block Executes whether or not an exception occurs.




1
II PU QUICK REVISION

, Example
try: except ValueError:
numerator = 50 print("Only INTEGERS should be entered")
denom = int(input("Enter the denominator: ")) else:
quotient = numerator / denom print("The result of division operation is",
print("Division performed successfully") quotient)
except ZeroDivisionError: finally:
print("Denominator as ZERO is not allowed") print("OVER AND OUT")

Definition – Exception Handling
Exception handling refers to the process of responding to the occurrence of exceptions during the
execution of a program. This is typically done using try, except, finally, and else blocks in Python.
Need for Exception Handling
Essential to prevent program crashes by capturing and managing runtime errors.
 Separates main program logic from error detection and correction code.
 The compiler/interpreter tracks the exact error location.
 Applicable to both user-defined and built-in exceptions.

Chapter 2 - File Handling
Text file Binary file
Text file stores information in ASCII characters. Binary files are used to store binary data such
as images, audios, videos and so on.
Each line of text is terminated with a special There is no delimiter in binary file.
characters known as EOL (End of Line).
Text files are easy to understand because these Binary files are difficult to understand.
files are in human readable format.
Extension: .txt, .py, .csv Extension: .dat, .jpg, .mp3
Character translation occur. There is no character translation.

Methods in File Handling
Method Syntax Example
open() file_object=open(flilename,mode) f=open(“sample.txt”,”r”)
close() file_object.close() f.close()
read() file_obect.read(n) f.read(5)
readline() file_object.reaadline() f.readline(10)
readlines() file_object.reaadlines() f.readlines()
write() file_object.write(string) f.write(“python”)
writelines() file_object.writelines(list of string) lines=[“hello\n”,”how are you\n”,”program”]
f.writelines(lines)
tell() file_object.tell() f.tell()
seek() f.seek(offset[,reference_point]) f.seek(5,0)
dump() pickle.dump(data_object,file_object) Listvalues=[1,’kavi’,’f’,26]
pickle.dump(listvalues,f)
load() pickle.load(file_object) pickle.load(f)
with clause with open(file_name, access_mode) with open("myfile.txt", "r+") as myObject:
as file_object: content = myObject.read()
# File operations

Methods and Definition
Method Definition
open() Python provides the open() function to open a file.
close() It is used to close a file and release the memory.
read() It reads the specified number of bytes from a file.


2
II PU QUICK REVISION

Written for

Institution
Secondary school
Course
School year
2

Document information

Uploaded on
March 11, 2026
Number of pages
13
Written in
2025/2026
Type
Class notes
Professor(s)
Priya
Contains
12 class

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
preethams

Get to know the seller

Seller avatar
preethams
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 month
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions