0% found this document useful (0 votes)
3 views

Pps Notes Unit-1 (2024 Pattern)

The document provides an overview of problem-solving concepts, programming, and Python programming. It outlines the steps in problem-solving, types of problems, and the role of computers in solving them, along with difficulties faced in problem-solving. Additionally, it discusses Python's features, history, future, and various programming paradigms.

Uploaded by

itsmedon09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Pps Notes Unit-1 (2024 Pattern)

The document provides an overview of problem-solving concepts, programming, and Python programming. It outlines the steps in problem-solving, types of problems, and the role of computers in solving them, along with difficulties faced in problem-solving. Additionally, it discusses Python's features, history, future, and various programming paradigms.

Uploaded by

itsmedon09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

PPS Unit-I SKNSITS

SKN SINHGAD INSTITUTES OF TECHNOLOGY & SCIENCE


Department of First Year Engineering
Programming and Problem Solving
Unit- 1 Notes

Unit I: Problem Solving, Programming and Python Programming

1.1 General Problem Solving Concepts

1.1.1 Problem Solving in Everyday Life:


Q.1. Define Problem. What are steps in problem solving?
Definition of problem
Problem is defined as a situation or issue or condition which needs to be solve to
achieve a specific goal.
Steps in problem solving
1. Identify the problem - You need to be clear about what exactly the problem
is. If the problem is not identified then it cannot be solved. example- when you
want to learn a language then first identify which language do you want to learn
2. Understand the problem - Here problem should be defined properly so that
it helps in understanding the problem more. It helps to understand knowledge
base of the problem. It helps in finding a target for what you want to achieve.
3. Identify alternative ways to solve the problem - This step is very crucial
because until and unless we explore all options, finding a correct solution is
next to possible. This involves the process to create a list of solutions.
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

1
PPS Unit-I SKNSITS

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.

1.1.2 Types of problems:

Q. 2. Explain types of problems in detail?


Ans:
Problem can be categorized into two types depending on how the solution is found out or
the approach which is followed to get that solution.
(i) Algorithmic solution
(a) These problems are solved by following some procedure or steps.
(b) For example: baking a cake. It can be done by following a series of instruction
And we can expect results.
(c) Here following some predefined process needs to be done.
(d) Here solution is quite straight forward.
(ii) Heuristic solution
(a) These types of problems solved using knowledge based i.e. by collecting
information about the problem.
(b) For example: Expanding one’s business.
2
PPS Unit-I SKNSITS

(c) In this type of approach there is no straight forward defined path which we can
follow to solve a problem.
(d) We need to build that path based on trial and error.
(e) In this approach experience and knowledge is very important.

1.1.3 Problem Solving with computers:

Q. 3. Write a note on Problem solving with computers.


Ans: Computer is a multi-purpose electronic machine which is used for storing,
organizing and processing the data.
Computer is not able to find the solution by itself; rather the computer is a machine
which follows the instruction given by programmer to solve any problem.
So all the efforts required to understand the problem and define procedure to solve that
problem are taken by programmer ( a human being).

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:
o What input is required for achieving expected output?
o Expected output of the problem.
o Current method of solving the problem.
o Can the problem or part of the problem be more effectively solved by a
software solution?
o Computers are built to deal with algorithmic solutions, which are often
difficult or very time consuming for humans.

3
PPS Unit-I SKNSITS

Solution:
o Solution means the instructions listed during problem solving – the instructions
that must be followed to produce the best results.
o The result may be: More efficient, faster, more understandable or reusable.
Results:
o The result is outcome or the completed computer assisted answer.
o May take any form: Printout, updated files, output to monitor speakers, etc.
Program:
o Program is the set of instructions that make up the solution after they have been
coded into a particular computer language.

1.1.4 Difficulties with problem solving:

Q.4. Explain the difficulties with Problem solving?


Ans:
o Some people may not have got training regarding how to solve problems.
o Some may not able to make a decision for fear it will not be the correct one.
o There may be inaccuracy in defining the problem correctly or may not generate
the sufficient list of alternatives.
o While selecting best alternative, they may skip better alternative due to urgency.
o The problem solving process is difficult. It takes practice as well as time to
perfect, but in the long run the process proves to be of great benefit.
o Illogical sequencing of instructions: In the process of problem solving on the
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.

4
PPS Unit-I SKNSITS

1.1.5 Problem Solving Aspects:

Q.6. What is modularization? Explain different approaches to design an


algorithm.
Ans:
Modularization:
For a complex problem, its algorithm is often divided into smaller units called modules.
This process of dividing an algorithm into modules is called as modularization.

Top down design approach:


• A top-down design approach starts by dividing the complex algorithm into one
or more functions.
• These functions can further be decomposed into one or more sub-functions, and
this process of decomposition is iterated until the desired level of module
complexity is achieved.
• Top-down design method is a form of stepwise refinement where we
begin with the topmost module and incrementally add functions that it calls.
• Therefore, in a top-down approach, we start from an abstract design and then at
each step, this design is refined into more concrete levels until a level is reached
that requires no further refinement.
Diagram: Top Down Approach

5
PPS Unit-I SKNSITS

Bottom up design approach:


• It is just reverse of top down approach.
• In bottom up design, we start with designing the most basic or concrete modules
and then proceed towards designing higher level modules.
• The higher level modules are implemented by using the operations performed by
lower level modules.
• Thus, in this approach sub-modules are grouped together to form higher level
module.
• All the higher level modules are clubbed together to form even higher level
modules.
• This process is repeated until the design of the complete algorithm is obtained.

Difference between Top down and Bottom up approach:

Top-Down Approach Bottom-Up Approach

Divides a problem into smaller units and then Starts from solving small modules and
solve it. adding them up together.

This approach contains redundant information. Redundancy can easily be eliminated.

Communication among steps is


A well-established communication is not required. mandatory.

Works on the concept of data-hiding


The individual modules are thoroughly analysed. and encapsulation.

Structured programming languages such as C use OOP languages like C++ and Java,
top-down approach. etc. uses bottom-up mechanism.

The modules must be related for


Relation among modules is not always required. better communication and work flow.

Primarily used in code implementation, test case


generation, debugging and module documentation. Finds use primarily in testing.

6
PPS Unit-I SKNSITS

1.1.6 Problem Solving Strategies:

Q.6. Explain the problem solving Strategies?


Ans.
Computer is a very powerful and versatile machine and can do any task given to it provided
that the programmer has already fed correct instructions to direct what, how and when the
steps have to be done to solve a particular problem. For this he should work to develop a
step by step solution to problem. These steps can be given as:
• Clearly define the problem in very simple and precise language.
• Analyse the problem to find out different ways to solve problem and decide the
best possible solution.
• Define the selected solution in a detailed step by step manner.
• Write the steps in a particular programming language so that it can be executed
by the computer.
The entire software development process is divided into a number of phases where each
phase performs a well defined task. Moreover, the output of one phase provides the input
for subsequent phase. The phases in the software development life cycle (SDLC) process
are summarized as follows:

Fig: Software Development Life cycle (SDLC)

7
PPS Unit-I SKNSITS

• 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.

• Design: The requirements documented in previous phase act as an input to the


design phase. In the design phase, core structure of the software is broken down
into modules. The solution of the program is specified for each module in the form
of algorithms or flowcharts.

• Implementation: In this phase, the designed algorithms are converted into program
code using any of the high level languages. The particular choice of language will
depend on the type of program, such as whether it is system or application program.
This phase is also called as construction phase as the code of 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.

8
PPS Unit-I SKNSITS

• 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.

1.2 Features of Python

Q.7. Explain various features of python.


Ans.
1. Simple: Python is simple and small language. Reading a program written in
python feels like reading English.
2. Easy to Learn: Python programming is clearly defined and easily readable.
3. Versatile: Python supports wide variety range of applications ranging from text
processing to Web applications
4. Free and Open Source: Python software is freely available on internet
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

2
1.3 History and Future of Python, Applications of Python

• Python is a general purpose interpreted interactive object oriented and high level
programming language.
• It was first introduced in 1991 by Guido van Rossum, a Dutch computer
programmer.
• The language places strong emphasis on code reliability and simplicity so that the
programmers can develop applications rapidly
• Python is multi-paradigm programming language, which allows user to code in
several different programming styles.
• Python supports cross platform development and is available through open
source. Python is widely used for scripting in Game menu applications effectively

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.
• 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 userbase 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.

3
Applications of Python

• Web Development
• Data Science and Analytics
• Artificial Intelligence (AI) and Machine Learning (ML)
• Game Development
• Mobile Application Development
• And many more

1.4 Programming Paradigms

Q1. Write a note on:

1. Monolithic Programming

2. Procedural Programming

3. Structured Programming

4. Object Oriented Programming

Ans. (i) Monolithic Programming Paradigm:

• Programs written using monolithic programming languages such as assembly language consist of global
data and sequential code. 

• 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. 

4
• 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.

5
(ii) Procedural Programming Paradigm:

In procedural programming language, a program is divided into n number of


subroutines that access global data.
To avoid repetition of code, each subroutine performs a well-defined task.
A subroutine that needs the service provided by another subroutine can call
that subroutine.
Therefore, with ‘jump’,’goto’, and ‘call’ instructions, the sequence of
execution of instructions can be altered.
For example, FORTRAN and COBOL are two popular procedural
programming languages.
Structure of a procedural program:

6
(iii) Structured Programming Paradigm:
Structured programming is also known as modular programming.
By using structured programming paradigm, programs are designed to
implement a logical structure on the program.
Due to this, program becomes more efficient and easier to understand.
Structured programming is used in large programs that require a large
development team to develop different parts of the same program.
Structured programming employs a top-down approach in which the overall
program structure is broken down into separate modules.
Due to this top-down approach, the code is loaded into memory more
efficiently and also can be reused in other programs.
Modules are coded separately and once a module is written and tested
individually, it is then integrated with other modules to form the overall
program structure.
Structured programming is based on modularization. Modularization groups
related statements together into modules.
Modularization makes programming easier to write, debug and understand.

7
PPS Unit-I SKNSITS

Advantages:
o Structured programming is used to write correct programs that are easy
to understand and change.
o Structured programming allows users to look at the big picture
first and then focus on details later by using modules.
o With modules, many programmers can work on a single, large
program, with each working on a different module.
o A structured program takes less time to be written than other programs.
o Also modules or procedures written for one can be reused in
program other programs as well.
o Each module performs a specific
task. Each module has its own
local data.
o A structured program is easy to change as well as understand because
o every procedure has meaningful names and has clear documentation
to identify the task performed by it.
o A structured program is easy to debug because each procedure is
specialized to perform just one task and every procedure can be
checked individually for the presence of any error.
o Structured programming gives more emphasis on code and the least
importance is given to the data.

Disadvantages:

• Structured programming is not data-centered.

• Global data is shared and may get modified.


• In structured programming, main focus is on functions.

8
(iv) Object-oriented Programming (OOP) Paradigm:
Object-oriented programming paradigm treats data as a critical element in the
program development.
In this paradigm, all relevant data and tasks are grouped together in entities known
as objects.
Object-oriented programming is task based as it considers operations.
Object-oriented programming is data-based as these operations are grouped with
relevant data in objects.

Every object contains some data and the operations, methods, or functions that
operate on that data.
Programs that need the object will access the object’s methods through a specific

interface. The interface specifies how to send a message to the object, that is, a
request for a certain operation to be performed.

9
PPS Unit-I SKNSITS

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.
o Inability to work with existing systems.
o Larger program size.
o Not suitable for all types of problems-for smaller problems it is in general not
suitable.

10

You might also like