Python Programming Notes (2nd Year B.
Tech)
Module 1: Programming for Everybody
1. Introduction to Python
Python is a high-level, interpreted, object-oriented programming language. It is easy to learn
and widely used in data science, AI, web development, and automation.
Features:
Simple and readable syntax
Interpreted language
Platform independent
Large standard library
2. Python Basics
print() – displays output
input() – takes user input
Indentation defines blocks
3. Variables and Data Types
Integer (int)
Float (float)
String (str)
Boolean (bool)
Example:
a = 10
b = 5.5
name = "Python"
4. Operators
Arithmetic: + - * / %
Relational: > < == !=
Logical: and or not
5. Control Statements
if-else
Used for decision making.
Loops
for loop
while loop
6. Functions
Functions are reusable blocks of code.
Syntax:
def function_name():
statements
Module 2: Python Data Structures
1. Lists
Ordered, mutable collection.
Common methods:
append()
insert()
remove()
pop()
clear()
len()
2. Tuples
Ordered, immutable collection.
Operations:
Access elements
Check membership using in
len()
3. Dictionaries
Key-value pairs.
Operations:
Access items
get()
Update values
len()
Module 3: Data Structures Using Python
1. Linked List
A collection of nodes where each node contains data and reference to next node.
2. Stack
Follows LIFO (Last In First Out).
Operations:
Push
Pop
3. Queue
Follows FIFO (First In First Out).
Operations:
Enqueue
Dequeue
Module 4: File Handling and Exception Management
1. File Handling
Used to store data permanently.
File modes:
r – read
w – write
a – append
r+ – read and write
2. File Functions
open()
read()
write()
close()
seek()
tell()
3. Exception Handling
Used to handle runtime errors.
Syntax:
try:
code
except:
error handling
Module 5: Pickle Module (Binary File Handling)
1. Pickling
Process of converting Python objects into byte stream.
Function: [Link]()
2. Unpickling
Process of converting byte stream back to Python object.
Function: [Link]()
3. Advantages of Pickle
Stores complex data types
Faster than text files
Exam Tips
Write syntax clearly
Mention file modes and functions
Add comments in programs
Practice lab experiments
Prepared for 2nd Year [Link] – Python Programming Lab