Topic 1.1

Problem Solving

FCT0035 Problem Solving & Programming

September 2025

Lesson Objectives

  • To define what is problem-solving
  • To describe the importance of problem-solving
  • To describe some common terms in programming such as:
    • Code
    • Program
    • Programming
  • To describe and apply the steps in problem-solving

Introduction to Problem Solving

Definition of Problem Solving

  • Problem solving is the process of:
    • Identifying an issue
    • Analyzing it
    • Finding effective solutions
  • It is a fundamental skill in programming, wherein the ability to effectively tackle challenges is essential for writing successful code.

Key Terms in Programming Context

  • A Program: A collection of instructions that a computer executes.
  • A Code: The written instructions in a programming language that a computer can interpret.
  • Programming: The act of creating a program through writing code using programming languages.

The Importance of Problem Solving in Programming

  • Problem solving is critical in programming because it allows developers to:
    • Create algorithms that can automate tasks
    • Solve real-world problems
    • Optimize processes
    • Debug codes
  • In programming, problem solving facilitates:
    • Understanding problems
    • Devising the most efficient and effective solutions.
  • Key Aspects of Programming
    • Programming is not just about writing code; it's focused on Algorithms, Efficient solutions, and Effective solutions.

The Problem-Solving Process

Steps in the Problem-Solving Process

  1. Identify the Problem
  2. Analyze the Problem
  3. Generate Possible Solutions
  4. Select the Best Solution
  5. Implement the Solution
  6. Evaluate the Results

Step 1: Identify the Problem

  • The first step is to clearly identify and define the problem.
  • This involves understanding the problem’s nature and scope.
  • Key Questions:
    • What is the problem?
  • Example: Calculate the average of three integers.

Step 2: Analyze the Problem

  • Inputs: Determine what values are required by the process.
  • Outputs: Establish what values need to be calculated, produced, or displayed by the process.
  • Formula: Identify the formula to be used to derive the output from the inputs.
  • Example:
    • Inputs: Three integers (number1, number2, number3)
    • Outputs: The average of the three integers
    • Formula:

      ext{average} = rac{ ext{number1} + ext{number2} + ext{number3}}{3}

Step 3: Generate Possible Solutions

  • Solution 1:
    • Calculate the sum of the three integers, then divide the obtained sum by 3 to get the average.
    • Formula:

      ext{sum} = ext{number1} + ext{number2} + ext{number3}
    • Average:

      ext{average} = rac{ ext{sum}}{3}
  • Solution 2:
    • Directly utilize the average formula as stated above.
    • Formula:

      ext{average} = rac{ ext{number1} + ext{number2} + ext{number3}}{3}
  • Solution 3:
    • Calculate each integer divided by 3, then sum them.
    • Average:

      ext{average} = rac{ ext{number1}}{3} + rac{ ext{number2}}{3} + rac{ ext{number3}}{3}

Step 4: Select the Best Solution

  • Select the solution that is deemed easiest to understand and implement.
  • Example: Possible selections may include Solution 1 or Solution 2 rather than Solution 3.

Step 5: Implement the Solution

  • The implementation can be executed using the following code snippet:
  number1 = int(input('number 1 : '))
  number2 = int(input('number 2 : '))
  number3 = int(input('number 3 : '))
  average = (number1 + number2 + number3) / 3
  print('The average = ', average)

Step 6: Evaluate the Results

  • After implementing the solution, testing and evaluation of results are key.
  • Example:
    • Input values could be:
    • number1: 2
    • number2: 4
    • number3: 6
    • Resulting Output:
    • The average = 4.0

Key Takeaways

  • Problem-solving is crucial in programming.
  • The problem-solving process involves steps such as identifying and analyzing the problem.
  • For every problem, multiple solutions may exist, enabling the selection of the "best" one based on defined criteria.