DEV Community

Cover image for Python3 Programming - Exercise 5 a - Problem Analysis
Michael Otu
Michael Otu

Posted on • Updated on

Python3 Programming - Exercise 5 a - Problem Analysis

Analysis of a problem

In this exercise, we shall look into the creation of a solution to a given problem. Let us assume a very basic problem to do with. We will analyze and design an algorithm for the solution.

Sample problem

Problem analysis - Sample problem

Analysis

To analyze the sample problem above, there are three things we need to look out for in the given problem. These are:

  1. the input
  2. the output
  3. the process

The input

This is simply the parameters that are given in the problem, and for the above problem, they are:

  1. the total number of students, which is five.
  2. the individual scores, which are 40, 78, 91, 59 and 12.
  3. the overall score, which is 100.

The output

This is what the program is expected to do - the expected outcome, what the user would see, finally after the process. Usually, we look at the process ( calculations before the output). We are expected to compute the values for the:

  1. sum of the scores
  2. average of the scores
  3. number of students who scored above the average score
  4. number of students who scored below the average score

Note

Usually, the desired output dictates how to compute on the input to obtain the output.

The process

From the problem, we are to compute the sum of the scores and the others. Our focus here is to find how to achieve the output. Most often, there would be a straight forward formula to use, other than that we have to find it. So now, all we have to think about is how to compute the :

  1. sum of the scores
  2. average of the scores
  3. number of students who scored above the average score
  4. number of students who scored below the average score

Note

The result from the computation is what becomes our output though not all becomes the output.

continuation in exercise 5 b (Design of a solution)

Top comments (0)