UNIT I – INTRODUCTION TO PYTHON
1. Introduction to Python
Python is a high-level, interpreted, general-purpose programming language created by Guido van
Rossum. It emphasizes code readability and simplicity. Python supports object-oriented,
procedural, and functional programming styles.
2. Features of Python
Easy syntax, interpreted execution, portability, extensive standard library, dynamic typing, and
open-source nature make Python suitable for beginners and professionals alike.
3. Python Development Environment (IDLE)
IDLE provides an interactive shell, script editor, debugger, and supports syntax highlighting. It is
ideal for learning Python programming.
4. Python Standard Library
Python comes with a rich standard library that supports file I/O, system calls, mathematics, random
numbers, date and time operations, and more, reducing the need for external libraries.
5. Literals and Data Types
Literals represent fixed values. Numeric literals include integers, floats, and complex numbers.
String literals represent textual data. Boolean literals represent True or False values.
6. Variables and Identifiers
Variables store data values in memory. Identifiers are names given to variables, functions, and
classes. They must follow naming rules such as starting with a letter or underscore and avoiding
keywords.
7. Operators and Expressions
Operators perform operations on operands. Python supports arithmetic, relational, logical,
assignment, membership, and identity operators. Expressions are combinations of operators and
operands.
UNIT II – CONTROL STRUCTURES AND LISTS
1. Control Structures
Control structures determine the flow of execution of a program. Python supports selection,
iteration, and branching control structures.
2. Selection Control Statements
The if, if-else, and if-elif-else statements are used to make decisions based on conditions.
Indentation is mandatory and defines code blocks.
3. Looping Statements
Python provides while and for loops. While loop is condition-controlled, whereas for loop is
sequence-controlled.
4. Definite and Indefinite Loops
Definite loops execute a fixed number of times. Indefinite loops execute until a condition becomes
false.
5. Lists in Python
Lists are mutable sequences used to store multiple values. They support indexing, slicing, and a
wide range of built-in methods.
6. Tuples and Nested Lists
Tuples are immutable sequences. Nested lists are lists within lists, useful for representing matrices
and complex data.
UNIT III – FUNCTIONS, STRINGS AND EXCEPTION
HANDLING
1. Functions in Python
Functions are reusable blocks of code. They help reduce redundancy and improve modularity.
Functions can return values or perform tasks without returning values.
2. Function Arguments
Python supports positional, keyword, default, and variable-length arguments, making function calls
flexible.
3. Variable Scope and Recursion
Scope defines the visibility of variables. Recursion is a technique where a function calls itself to
solve a problem in smaller steps.
4. String Processing
Strings are sequences of characters. Python provides various string methods for searching,
modifying, and formatting strings.
5. Exception Handling
Exception handling allows programs to handle runtime errors gracefully using try, except, else, and
finally blocks.
UNIT IV – FILE HANDLING AND
OBJECT-ORIENTED PROGRAMMING
1. File Handling in Python
File handling allows permanent storage of data. Python supports text, binary, and CSV files with
various access modes such as read, write, and append.
2. Reading and Writing Files
Files can be read using read(), readline(), or readlines() methods and written using write() and
writelines() methods.
3. Object-Oriented Programming Concepts
OOP is based on classes and objects. It supports abstraction, encapsulation, inheritance, and
polymorphism.
4. Classes and Objects
Classes define blueprints for objects. Objects are instances of classes containing data members
and methods.
5. Advanced OOP Concepts
Includes constructors, class methods, static methods, inheritance types, abstract classes, operator
overloading, and method overriding.