PPS UNIT_1
PPS UNIT_1
PPS UNIT_1
Syllabus:
General Problem Solving Concepts- Problem solving in everyday life, types of
problems, problem solving with computers, difficulties with problem solving, problem
solving aspects, top down design, Problem Solving Strategies
Basics of Python Programming: Features of Python, History and Future of Python,
Programming Paradigm,
Features of Object Oriented Programming, Applications of Python Languages.
1
PPS Unit-I(2024 Pattern) DIT,Pimpri
4. Select the best way to solve the problem - Identify and evaluate pros and
cons of each possible solution and then select the best solution. Selecting
proper way from alternatives require a lot of study and need to study con-
sequences as well.
5. List instructions that enable you to solve the problem using
selected solution - Here we need to list out the steps which should
be followed so that anyone can solve the problem. This should be in
detail and precise at the same time.
6. Evaluate the solution - It mean to test the solution and check if the
result is satisfactory or not.
Example: I am always late for college
(i) Identification: getting late for college.
(ii) Understanding: (List out probable reasons of or getting late)
(Sleeping late, waking up late, Transportation, etc.)
(iii) List out alternative ways – (Solutions)
(a). Sleeping early at home.
(b). Waking up early.
(c). Waking alarm.
(d). Resolving travelling issue.
(iv) Select the best way – Sleeping early in night.
(v) List out the procedure
(a). Having dinner as early as possible.
(b). Avoid use of mobile phones in night.
(c). Completing homework as early as possible.
(d). Then going early to bed.
(vi) Evaluate the solution: Reached College on time.
2
PPS Unit-I(2024 Pattern) DIT,Pimpri
Problem Definition:
Before a program is written for solving a problem, it is important to define the problem
clearly.
Define problem: Problem is defined as a situation or issue or condition which
needs to solve to achieve the goal.
For most of the software projects, the system analyst approach system users to
collect user requirements and define the problem that the system aims to solve.
System analyst typically looks at following issues:
3
PPS Unit-I(2024 Pattern) DIT,Pimpri
computer, one of the most complicated jobs for the problem solver is writing the
instructions.
Example: Consider a task to find which number is the maximum from a set of
three numbers. Near about everyone is immediately able to tell which is the
largest but several of them are unable to explain the steps they followed to get
the result. Computer is nothing but a machine that will perform only task that
the user can explain.
5
PPS Unit-I(2024 Pattern) DIT,Pimpri
Divides a problem into smaller units and then Starts from solving small modules and
solve it. adding them up together.
6
PPS Unit-I(2024 Pattern) DIT,Pimpri
Structured programming languages such as C use OOP languages like C++ and Java,
top-down approach. etc. uses bottom-up mechanism.
● Requirement Analysis: In this phase, the user’s expectations are gathered to know
why the software has to be built. The gathered requirements are analyzed to
decide scope of software. The last activity in this phase includes documenting
every identified requirement of the users in order to avoid any doubts regarding
functionality of software. The functionality, capability, performance and
availability of hardware and software components are all analyzed in this phase.
the software is generated in this phase. While constructing the code, the
development team checks whether the software is compatible with available
hardware that are mentioned in requirement specification document.
● Testing: In this phase all modules are tested together to ensure that the overall
system works well as a whole product. In this phase the software is tested using a
large number of varied inputs, also known as test data, to ensure the software is
working as expected by user’s requirements.
● Software development, training and support: After the code is tested and the
software or the program has been approved by the users, it is installed or
deployed in the production environment. In this phase it becomes very crucial to
have training classes for users of software.
● Maintenance: Maintenance and enhancement are ongoing activities that are done
to cope with newly discovered problems or new requirements. Such activities
may take a long time to complete as the requirement may call for the addition of
new code that does not fit original design or an extra piece of code, required to fix
an unforeseen problem.
9
PPS Unit-I(2024 Pattern) DIT,Pimpri
5. High Level Language: Programmers don’t have to worry about low level details
like managing memory used by program etc.
6. Interactive: Programs in python works in interactive mode
7. Portable (Platform Independent): Python is portable language. Program can
work similarly on different platform like window, Linux, Macintosh, Solaris etc.
8. Object Oriented: Python supports Object oriented style of programming like
C++, Java languages. It support features like C class, Objects, Inheritance etc.
9. Interpreted: Python is processed at run time by the interpreter. So no need to
compile program before executing it.
10. Scalability: Python support modular programming, so programmer can add
module at any stage of the program
11. Secure: Python programming environment is secure from tempering
History of Python:
● Python is created by Guido Van Rossum in the 1980s.
● Rossum published the first version of Python code (0.9.0) in February 1991 at the
CWI (Centrum Wiskunde & Informatics) in the Netherlands , Amsterdam.
● Python is derived from ABC programming language, which is a general-purpose
programming language that had been developed at the CWI.
10
PPS Unit-I(2024 Pattern) DIT,Pimpri
● Rossum chose the name "Python", since he was a big fan of Monty Python's
Flying Circus.
● Python is now maintained by a core development team at the institute, although
Rossum still holds a vital role in directing its progress.
Future of Python:
● Python’s user base is vast and growing – it’s not going away any time soon.
● Utilized by the likes of Nokia, Google, and even NASA for it’s easy syntax, it looks
to have a bright future ahead of it supported by a huge community of OS developers.
● Its support of multiple programming paradigms, including object-oriented Python
programming, functional Python programming, and parallel programming models
makes it a highly adaptive choice – and its uptake keeps growing.
11
PPS Unit-I(2024 Pattern) DIT,Pimpri
The global data can be accessed and modified from any part of the program.
A sequential code is one in which all instructions are executed in the specified
sequence.
In order to change the sequence of instructions, jump statements or ‘goto’
statements are used.
Structure of a monolithic program:
Advantages:
Monolithic programming language is used only for very small and simple
applications.
Monolithic programming language is used only for applications where
reusability is not a major concern.
Disadvantages:
Monolithic programs have just one program module as monolithic
programming languages do not support the concept of subroutines.
As it is containing just one program module, all the actions required
completing particular task are embedded within same application itself.
This makes the size of program large.
It is difficult to debug and maintain monolithic programs.
12
PPS Unit-I(2024 Pattern) DIT,Pimpri
Advantages:
This paradigm is used to write just correct programs.
Programs using this paradigm are easier to write as compared to
monolithic programming.
Disadvantages:
Writing programs is complex.
No concept of reusability.
It requires more time and effort to write programs.
Programs are difficult to maintain.
Global data is shared and therefore may get altered (mistakenly).
Advantages:
Structured programming is used to write correct programs that are
easy to understand and change.
14
PPS Unit-I(2024 Pattern) DIT,Pimpri
Disadvantages:
Structured programming is not data-centered.
Global data is shared and may get modified.
In structured programming, main focus is on functions.
15
PPS Unit-I(2024 Pattern) DIT,Pimpri
Advantages:
OOP is used for simulating real world problems on computers because the
real world is made up of objects.
Programs written using OOP are data centered.
Programs are divided in terms of objects and not procedures.
Functions that operate on data are tied together with the data.
Data is hidden and not accessible by external functions.
New data and functions can be easily added as and when required.
It follows a bottom-up approach for problem solving.
Disadvantages:
o It requires more data protection.
16
PPS Unit-I(2024 Pattern) DIT,Pimpri
3. It simulates the real world entity. So It doesn't simulate the real world. It
real-world problems can be easily works on step by step instructions
solved through oops. divided into small parts called
functions.
17
PPS Unit-I(2024 Pattern) DIT,Pimpri
1. Classes
A class is user-defined data type used to describe something in the world,
such as occurrences, things, external entities, and so on.
A class describes template or blueprint that describes the structure and
behavior of a set of similar objects.
Once we have definition for a class, a specific instance of that class can be
easily created.
For eg. Consider a class student. A student has attributes such a roll_no,
name, course and aggregate. The operations that can be performed on its
data may include ‘getdata’, ‘setdata’,’editdata’ and so on.
A class is collection of objects.
2. Objects
Object is basic unit of object-oriented programming.
Object is basic run-time entity in an object-oriented system.
Anything having its own properties can be considered as an object.
For example flower is an object having properties such as name, fragrance,
etc.
An object is a collection of data members and associated member function
also known as methods shown in figure1 below:
18
PPS Unit-I(2024 Pattern) DIT,Pimpri
Object Name
Attribute 1
Attribute 2
.........
Attribute N
Function 1
Function 2
.........
Function N
19
PPS Unit-I(2024 Pattern) DIT,Pimpri
20
PPS Unit-I(2024 Pattern) DIT,Pimpri
Student
Undergraduate Postgraduate
Student Student
We can inherit two classes from the class student- undergraduate students and
postgraduate students (refer figure4). These two classes will have all the
properties of class students and in addition to that it will have even more
specialized members.
When a derived class receives a message to execute a method, it finds the
method in its own class. If it finds the method, then it simply executes it. If
the method is not present, it searches for that method in its superclass. If the
method is found, it is executed; otherwise, an error message is reported.
5. Polymorphism
Polymorphism refers to having several different forms.
While inheritance is related to classes and their hierarchy, polymorphism on
other hand, is related to methods.
Polymorphism is a concept that enables the programmers to assign a different
meaning or usage to a method in different context.
Polymorphism exist when a number of subclasses is defined which have
methods of same name.
Polymorphism can also be applied to operators.
22
PPS Unit-I(2024 Pattern) DIT,Pimpri
7. Reusability
Reusability means developing codes that can be reused either in the same
program or in the different programs.
Reusability is attained through inheritance, containership and
polymorphism.
8. Delegation
To provide maximum flexibility to programmers and to allow them to
generate a reusable code, object oriented languages also support delegation.
In composition, an object can be composed of other objects and thus, the
object exhibits a ‘has-a’ relationship.
In delegation, more than one object is involved in handling a request. The
object that receives the request for a service, delegates it to another object
called its delegate.
Delegation means that one object is dependent on another object to provide
functionalities.
The property of delegation emphasizes on the ideology than a complex object
is made of several simpler objects.
For example, our body is made up of brain, heart, hands, eyes, ears, etc. The
functioning of the whole body as a system rests on the correct functioning of
the parts it is composed of.
Delegation is different from inheritance in the way that two classes that
participates in inheritance share ‘is-a’ relationship; however, in delegation,
they have a ‘has-a’ relationship.
9. Data Abstraction
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.
23
PPS Unit-I(2024 Pattern) DIT,Pimpri
24
PPS Unit-I(2024 Pattern) DIT,Pimpri
1. Web Development:
Python is widely used to build robust and scalable web applications using
frameworks like Django, Flask, and FastAPI. These frameworks simplify
development by providing tools for database interaction, routing, and security.
Python’s versatility allows developers to create anything from personal blogs to
enterprise-level websites.
2. Data Science and Analytics:
Python is a go-to language for data scientists due to libraries like Pandas, NumPy,
and Matplotlib. It allows users to clean, analyze, and visualize data efficiently.
Combined with machine learning libraries like scikit-learn, Python enables
predictive analysis and insights generation.
3. Artificial Intelligence and Machine Learning:
Python plays a crucial role in AI and ML applications with frameworks like
TensorFlow and PyTorch. It is used for tasks like natural language processing,
image recognition, and building recommendation systems. Its simplicity and vast
community support make it ideal for AI projects.
4. Scientific Computing:
Python supports high-performance scientific computing with libraries like SciPy
and SymPy. Researchers use it for complex simulations, solving mathematical
problems, and running statistical models. Its integration with Jupyter Notebooks
enhances collaborative research.
5. Automation and Scripting:
Python is frequently used to automate repetitive tasks such as file handling, data
entry, and testing. Libraries like Selenium and PyAutoGUI allow for automated
web interactions and GUI control. This makes it invaluable for increasing
productivity in various domains.
6. Game Development:
Python is used in the gaming industry for prototyping and developing simple 2D
and 3D games. Libraries like Pygame and Panda3D provide tools for game
mechanics, animations, and graphics. Python’s readability helps game developers
quickly iterate and test ideas.
7. IoT and Robotics:
Python is a preferred language for IoT and robotics applications, especially with
platforms like Raspberry Pi and Arduino. It enables developers to interact with
sensors, actuators, and APIs. Python simplifies the control of hardware devices in
real-time projects.
8. Networking and Cybersecurity:
Python is popular for developing tools and scripts in network programming and
cybersecurity. Libraries like Scapy and Paramiko assist in packet sniffing, SSH
connections, and testing network vulnerabilities. It is also used to automate
security audits and penetration testing.
9. Desktop Application Development:
Python enables the development of interactive desktop applications using
frameworks like Tkinter, PyQt, and Kivy. These tools provide support for
25
PPS Unit-I(2024 Pattern) DIT,Pimpri
26
PPS Unit-I(2024 Pattern) DIT,Pimpri
27
PPS Unit-I(2024 Pattern) DIT,Pimpri
C. Comments
· The comments are ignored by the interpreter and are used to add additional
information about the program or its statements.
· They can be written anywhere in the program.
· Two way comments can be given in Pyhton
1. One line comments using (#)
2. Multi line comments using (‘’’ ‘’’)
· Comments in Python begins with ’ #’ character.
· A comment may appear at the beginning of a line or can be placed after
whitespace or code, but not within a string literal.
Example:1
#This is first Python Program
print(“Hello World”) # prints Hello World
Example: 2
''' program is written for addition
Of two numberd '''
x=10
y=20;
Print(x+y)
D. Indentation
● White space at the beginning of the line is called indentation.
● These white spaces or the indentation are very important in python.
● In python program, the leading white space and tabs at the beginning of the
logical line determines the indentation level of logical line.
● All statements inside block should be at same indentation level.
● Python checks the indentation level very strictly and gives an error if
indentation is not correct.
Use of indentation:
● In most of the programming languages, indentation has no effect on program
logic. It is used to align statements to make the code readable.
● However, in python indentation is used to associate and group statements.
Example:
Program to find number is even or odd
num = int(input("Enter a number: "))
if (num % 2) == 0:
print("Number is even")
else:
print("Number is Odd")
28