What is Problem Solving?
Problem-solving is the process of analyzing a problem, designing a solution, and implementing it using a programming language. In Python, problem-solving involves writing structured and logical code to achieve a desired outcome.

Steps in Problem Solving:
- Understanding the Problem: Identify the requirements and constraints.
- Devising a Plan: Develop a step-by-step strategy to solve the problem.
- Writing the Algorithm: Create a sequence of instructions to solve the problem.
- Writing the Pseudocode: Represent the solution in a high-level structured format before coding.
- Converting Algorithm to Code: Write the Python program based on the algorithm.
- Testing and Debugging: Run the program, check for errors, and refine the solution.
Algorithm, Pseudocode, and Flowchart
What is an Algorithm?
An algorithm is a step-by-step procedure or a set of well-defined rules used to solve a specific problem or perform a computation. It takes some input, processes it, and produces an output.
Key Characteristics of an Algorithm:
- Well-Defined Steps – The algorithm should follow a clear sequence of steps.
- Input – It may take zero or more inputs.
- Output – It should produce at least one output.
- Definiteness – Each step must be unambiguous and precise.
- Finiteness – The algorithm must terminate after a finite number of steps.
- Effectiveness – The steps should be simple enough to be executed in a reasonable amount of time.
Example of an Algorithm:
Algorithm to Add Two Numbers:
- Start
- Take two numbers as input
- Add the numbers
- Display the sum
- Stop
What is Pseudocode?
Pseudocode is a simplified, language-independent way of writing an algorithm using plain English and programming-like constructs.
Example of Pseudocode:
BEGIN
PRINT "Enter first number"
READ num1
PRINT "Enter second number"
READ num2
sum_result ← num1 + num2
PRINT "The sum is: ", sum_result
END
Pseudocode helps in understanding the logic before implementing it in an actual programming language.
What is a Flowchart?
A flowchart is a visual representation of an algorithm using symbols and arrows to show the flow of execution.
Flowchart Symbols:
- Oval: Start/End
- Parallelogram: Input/Output
- Rectangle: Process (Operations like addition, subtraction, etc.)
- Diamond: Decision-making
Writing a Simple Python Program
Now, let’s convert the algorithm into a Python program.
Python Code:
# Program to add two numbers
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
# Calculate sum
sum_result = num1 + num2
# Display result
print("The sum is:", sum_result)
Explanation:
- The
input()
function takes user input. - The numbers are converted to integers using
int()
. - The sum is calculated and displayed using
print()
.
Decomposition in Problem Solving
Decomposition is the process of breaking a complex problem into smaller, manageable sub-problems.
Example:
Consider a program that calculates the average of three numbers. Instead of writing a single block of code, we can:
- Take three numbers as input
- Calculate the sum
- Divide by three to get the average
- Display the result
This approach makes debugging and modification easier.
Python Code for Average Calculation:
# Program to calculate the average of three numbers
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))
# Compute average
average = (num1 + num2 + num3) / 3
# Display result
print("The average is:", average)
Conclusion
- Problem-solving involves understanding a problem, designing an algorithm, and implementing a solution in Python.
- Pseudocode helps in structuring the logic before coding.
- Algorithms and flowcharts help in structuring the solution before coding.
- Breaking down complex problems into smaller tasks makes them easier to solve.