Programming paradigms attempt to classify programming languages according to their features and capabilities. In this article, you will learn what are the programming paradigms available for python language. The python programming language supports following programming paradigms.
- Imperative programming paradigm
- Structural Programming Paradigm
- Procedural Programming
- Functional Programming
- Object-Oriented Programming Paradigm
- Event-Driven Programming paradigm
Imperative Programming Paradigm
The word “imperative” means urgent or give command. In this programming paradigm the commands are executed in step-by-step manner. It just change the state within the program. Therefore, cannot run complex codes in imperative programming. The languages like C, FORTRAN, BASIC, PL/I supports this paradigm.
x = 10 y = 20 x + y 30 //each of the above code is executed line by line
Structured Programming Paradigm
We can use structured programming when the programming language supports it. In this paradigm, the program is written clearly by dividing the program into blocks, procedures, functions, using if-else and loop constructs. That is the reason, structured programming is divided into –
procedural programming paradigm and
function programming paradigm.
Procedural Programming Paradigm
The procedural programming paradigm is supported by those languages that can call procedures. A procedure is a routine, subroutine, or function that execute commands in step-by-step manner.
A procedural programming is also
imperative in nature and change the state of the program itself. Imperative programming give commands to computer describing “how” a program operates. It uses algorithms which is step-by-step method of solving problems.
Functional Programming Paradigm
The functional programming uses procedures called functions and the program is structured using many functions whose nature is similar to a mathematical function.
It takes the
declarative approach and does not change the state of the program. Output of the functional programming is dependent on the arguments it takes. Similar to a mathematical function, from one set to another set. The declarative nature of functional programming focus more on “what to do” than “how to do” approach of imperative programming paradigm.
Remember that a subroutine is not a mathematical function. Therefore, functional programming is popular in academics. Java, C, FORTRAN, BASIC are few examples of structural languages.
Object-Oriented Programming Paradigm
The object-oriented approach translates the real world object into abstract objects with properties and methods. The object is created out of a template called
class. The properties are the description or attributes of an object and the behavior of the object is modeled by its methods.
Event-Driven Programming Paradigm
In this programming paradigm, the program waits and listens for an event to happen. The moment an event take place, the event handler will respond to the event with appropriate message.