Chapter 2
Chapter 2
Python Programming
Using Problem Solving Approach
Reema Thareja
All the commands and data values are expressed using 0s and 1s, corresponding to the off and on electrical states in a
computer.
Although there is no standard rule that defines a 4GL, certain characteristics include the following:
• The instructions of the code are written in English-like sentences.
• They are non-procedural, so users concentrate on the ‘what’ instead of the ‘how’ aspect of the task.
• The code written in a 4GL is easy to maintain.
• The code written in a 4GL enhances the productivity of programmers, as they have to type fewer lines of code to get
something done. A programmer supposedly becomes 10 times more productive when he/she writes the code using a
4GL than using a 3GL. 7
Fifth-generation programming languages (5GLs) are centered on solving problems using the constraints given to a
program rather than using an algorithm written by a programmer.
Typical examples of 5GLs include Prolog, OPS5, Mercury, and Visual Basic.
• Main focus on functions. © OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED.
Object Oriented Programming (OOP)
In the object oriented paradigm, the list and the associated operations are treated as one entity known as an object.
12
14
Data abstraction refers to the process by which data and functions are defined in such a way that only essential details
are revealed and the implementation details are hidden. The main focus of data abstraction is to separate the interface
and the implementation of a program.
Data encapsulation, also called data hiding, is the technique of packing data and functions into a single component
(class) to hide implementation details of a class from the users. Users are allowed to execute only a restricted set of
operations (class methods) on the data members of the class. Therefore, encapsulation organizes the data and methods
into a structure that prevents data access by any function (or method) that is not specified in the class. This ensures the
integrity of the data contained in the object.
16
• OOP supports code reusability to a great extent. © OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED.
Demerits of OOP Languages
Programs written using object oriented languages have greater processing overhead as they demand more resources.
• Requires more skills to learn and implement the concepts.
• Beneficial only for large and complicated programs.
• Even an easy to use software when developed using OOP is hard to be build.
• OOP cannot work with existing systems.
• Programmers must have a good command in software engineering and programming methodology.
18