Subject Name - Problem Solving using
Python(PSP)
Subject Code - CSE1003
Topic Covered -Module -1(Introduction to problem Solving)
CO1 - Develop solutions through algorithms and flowcharts
Ms. Deepanshi
Assistant Professor
Applied Science
Problem Solving definition and steps
Definition
In the context of programming, problem-solving is the systematic process of
breaking down a complex task into smaller, manageable parts to create a
working computer program.
It is not just about writing code; it is about finding the right logic to solve a
specific issue efficiently.
Steps in Problem Solving
A standard, methodical approach ensures that your solution is accurate and
easy to maintain.
1. Analyze and Understand the Problem: Clearly identify what needs to be
solved. Determine the required Inputs (data you have), the
expected Outputs (results you want), and any constraints or rules you
must follow.
2. Break it Down (Decomposition): Divide a large, complex problem into
smaller sub-problems. This makes it easier to design and debug
individual parts, like creating separate functions for different tasks.
3. Develop an Algorithm: Create a detailed, step-by-step roadmap for the
solution in plain English. A good algorithm should be precise, finite (it
must end), and produce the correct result.
4. Represent the Solution (Flowchart/Pseudocode):
Flowchart: A visual diagram using shapes and arrows to show the flow of
logic.
Pseudocode: A simplified, "fake code" version of your logic that uses
structured language but ignores strict Python syntax.
5. Coding (Implementation): Convert your finalized logic into actual Python
code. This is where you use Python’s syntax, such as variables, loops, and
built-in functions, to build the program.
6. Testing and Debugging: Run your program with different inputs to see if
it works as expected. If you find errors (bugs), trace the logic and fix
them until the program is perfect.
7. Optimize for Efficiency: Once the program works, refine it to run faster
or use less memory. In 2026, this often involves using efficient data
structures (like sets or dictionaries) or Python’s powerful built-in
libraries.
Simple Example: Finding the Area of a Circle
Step 1 (Analyze): Input is radius (r ). Output is Area.
Step 2 (Algorithm):
1. Start.
2. Get radius (𝑟).
3. Calculate Area=3.14 ×r × r .
4. Print Area.
5. Stop.
Step 3 (Python Code):
r = float(input("Enter radius: "))
area = 3.14 * r * r
print("The area is:", area)
Developing an Algorithm
Algorithms are the foundation of programming. Each algorithm has a set
of instructions or procedures, designed to achieve a specific goal.
It can be simple, involving a sequence of basic operations or complex
following a multi-step process with different data structures and logic.
No matter how complex algorithms can get, their main goal is to take in
input, process it, and provide the answer you need.
How to Write an Algorithm?
Example
Let's try to learn algorithm-writing by using an example.
Problem − Design an algorithm to add two numbers and display the result.
step 1 − START
step 2 − declare three integers a, b & c
step 3 − define values of a & b
step 4 − add values of a & b
step 5 − store output of step 4 to c
step 6 − print c
step 7 − STOP
Algorithms tell the programmers how to code the program. Alternatively, the
algorithm can be written as −
step 1 − START ADD
step 2 − get values of a & b
step 3 − c ← a plus b
step 4 − display c
step 5 − STOP
In design and analysis of algorithms, usually the second method is used
to describe an algorithm.
It makes it easy for the analyst to analyze the algorithm ignoring all
unwanted definitions.
He can observe what operations are being used and how the process is
flowing.
We design an algorithm to get a solution of a given problem. A problem can be
solved in more than one ways.
Flowcharts and Pseudocode
FLOW CHART
• Flow chart is defined as graphical representation of the logic for problem
solving.
• The purpose of flowchart is making the logic of the program clear in a visual
representation.