PYTHON PROGRAMMING
Vishnu Mohan S
MVJ College of Engineering
September 26, 2025
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 1 / 34
ALGORITHMS – Recursion
Recursion
Technique of solving a problem by breaking it down into smaller and
smaller subproblems until a problem is reached that can be easily
solved.
Recursion involves a function calling itself until a specified condition
is met.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 2 / 34
ALGORITHMS – Recursion
Example illustration of recursion
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 3 / 34
FLOWCHARTS
Graphical or symbolic representation of a process.
Help the viewers to visualize the logic of the process.
Each step is depicted by a different symbol with short description.
Symbols are linked together to show the flow of logic.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 4 / 34
FLOWCHARTS
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 5 / 34
FLOWCHARTS – Significance
Show sequence of steps clearly.
Improve communication between programmers and users.
Help understand complex/lengthy problems.
Act as a blueprint for coding.
Aid in debugging and error detection.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 6 / 34
FLOWCHARTS
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 7 / 34
FLOWCHARTS
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 8 / 34
FLOWCHARTS – Advantages & Limitations
Advantages:
Excellent communication tool.
Help in problem analysis and documentation.
Guide/blueprint for coding.
Ensure error-free program development.
Useful for debugging.
Limitations:
Time-consuming and laborious to draw.
For complex programs, flowcharts become clumsy.
Small changes may require complete redrawing.
Essentials may get lost in technical details.
No strict standards for required level of detail.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 9 / 34
PSEUDOCODES
Informal, high-level description of an algorithm.
Uses programming-like structure but not exact syntax.
Focuses on logic, ignores coding details.
Meant for human reading, not machine execution.
Outlines logic in short English phrases.
Easy to translate into code.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 10 / 34
PSEUDOCODES
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 11 / 34
PSEUDOCODES
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 12 / 34
PSEUDOCODES
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 13 / 34
PSEUDOCODES – Significance
Omits non-essential details (e.g., variable declarations, system-specific
code).
Flowcharts can be considered graphical alternatives.
Helps design solutions before coding.
Allows even non-programmers to follow logic.
Flexible – no strict standards for writing.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 14 / 34
PROGRAMMING PARADIGMS
A programming paradigm defines how the structure and basic
elements of a program are built.
Some languages follow a single paradigm strictly, others combine
multiple paradigms.
Types:
Monolithic Programming
Procedural Programming
Structured Programming
Object-Oriented Programming
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 15 / 34
Monolithic Programming
Programs consist of global data and sequential code.
Data can be accessed or modified from anywhere.
No concept of subroutines or modularization.
Large program size, difficult to debug and maintain.
Suitable only for very small/simple applications.
Examples: Assembly language, BASIC.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 16 / 34
Procedural Programming
Program is divided into multiple subroutines (functions/procedures).
Each subroutine performs a well-defined task.
Avoids repetition of code.
Uses jump, goto, call instructions.
FORTRAN and COBOL are examples.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 17 / 34
Procedural Programming – Pros and Cons
Advantages:
Easier to write than monolithic programs.
Focuses on correctness.
Disadvantages:
Writing programs is complex and time-consuming.
No concept of reusability.
Programs are difficult to maintain.
Global data may get altered mistakenly.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 18 / 34
Structured Programming
Also called modular programming.
Programs divided into modules using a top-down approach.
Each module handles a specific part and is coded/tested separately.
Uses sequence, selection, and repetition.
Supported by C, Pascal.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 19 / 34
Structured Programming – Features
Advantages:
Improves clarity, reduces errors, increases reusability.
Multiple programmers can work on different modules.
Modules or procedures can be reused.
Easy to debug and maintain.
Introduced functional abstraction (focus on what, not how).
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 20 / 34
Structured Programming – Disadvantages
Not data-centered.
Global data shared among modules may be accidentally changed.
Focus is on functions rather than data.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 21 / 34
Object-Oriented Programming (OOP)
Definition: OOP treats data as the central element in program
development. Programs are organized around objects and their
interactions.
Key Features:
Programs are data-centered.
Objects store data and methods.
Provides modularity and reusability.
Uses bottom-up approach.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 22 / 34
Main Features of OOP
Classes – Blueprint for creating objects.
Objects – Instances of classes.
Methods – Functions inside objects.
Inheritance – Reuse code across classes.
Polymorphism – One function, many forms.
Encapsulation – Hides internal details.
Message Passing – Objects communicate.
Containership – Class containing objects of other classes.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 23 / 34
Classes and Objects
Class: A user-defined data type that defines data members (attributes)
and methods (functions). Object: An instance of a class, uniquely
identified by its name, with its own data values.
Example: Student Class
class Student:
def __init__(self, roll_no, name, course):
self.roll_no = roll_no
self.name = name
self.course = course
def showdata(self):
print("Roll Number:", self.roll_no)
print("Name:", self.name)
print("Course:", self.course)
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 24 / 34
Objects with Data and Functions
Every object has its own set of values (called its state).
Objects communicate by sending messages (method calls).
Example:
Object: Person
Data: Name, Age, Sex
Methods: Speak(), Walk(), Listen()
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 25 / 34
Inheritance
Mechanism to create a new class (child) from an existing class
(parent).
Child class inherits data members and methods from parent.
Additional properties/methods can be added in child.
Single Inheritance: One parent, one child.
Multiple Inheritance: Child inherits from multiple parents.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 26 / 34
Polymorphism
Meaning: ”Many forms” – same operation behaves differently
depending on objects.
Allows use of same method name for different implementations.
Example:
2 + 3 = 5 (integer addition)
"AI" + "ML" = ”AIML” (string concatenation)
Method Overriding: Redefining parent class method in child class.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 27 / 34
Containership (Composition)
Containership is also called Composition.
It represents a has-a relationship.
One class contains object(s) of another class as its members.
Used to build complex objects from simpler ones.
Improves modularity and code reuse.
Example: A School class containing multiple Student objects.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 28 / 34
Delegation
Delegation is a design technique where one object hands over
responsibility to another object.
Represents a has-a relationship, but focuses on behavior forwarding.
The delegating object does not perform the work itself — it calls
another object to do it.
Promotes loose coupling between classes.
Easier to modify or replace behavior without changing the delegating
class.
Example: A Car class delegating the starting operation to its Engine
object.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 29 / 34
Data Abstraction and Encapsulation
Data Abstraction: Shows only essential details, hides
implementation.
Data Encapsulation: Binds data and methods together, restricts
access to data.
Improves data security and object integrity.
Access Levels:
public – accessible anywhere.
protected – accessible in class and subclasses.
private – accessible only within the class.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 30 / 34
Merits of OOP
Eliminates code redundancy, improves reusability.
Easier to maintain and upgrade.
Real-world objects can be easily mapped.
Secure programs due to data hiding.
Easy to add new features without affecting existing code.
Supports modularity and maintainability.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 31 / 34
Demerits of OOP
More complex to learn for beginners.
Programs may be slower due to message passing and object handling.
Requires more memory because of objects and classes.
Not suitable for very small programs.
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 32 / 34
Applications of OOP
GUI-based applications
Simulation and modeling
Artificial Intelligence and Expert Systems
Office Automation Systems
Computer-Aided Design (CAD)
Networking and device programming
Decision Support Systems
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 33 / 34
Thank You
Thank You!
Vishnu Mohan S (MVJ College of Engineering) PYTHON PROGRAMMING September 26, 2025 34 / 34