Concepts / Introduction to Problem Solving

Introduction to Problem Solving

Do not treat a program as something to copy mechanically. Try to solve the problem yourself first, then ask smart questions when you need help.

  • Programming

Begin with the Problem

Writing a Python program is not only a matter of producing instructions. It is also an exercise in problem solving. You begin with a problem, think about how it could be solved, and then create a Python program or script that expresses the solution. The more programs you create yourself, the more comfortable you become with both Python and problem-solving.

Key point

Do not treat a program as something to copy mechanically. Try to solve the problem yourself first, then ask smart questions when you need help.

Trace the Solution Path

ProblemIndependent attemptTry solving it firstSmart questionsAsk when help is neededAlgorithmA general solving processPython program orscriptSmaller piecesUseful as programs growstartthenclarify the approachexpress the solutionas the program grows
What happens as you turn a problem into a working Python program or script?

The diagram is a practical learning path rather than a complete list of every stage that might appear in a programming project. Its central idea is that a program is the result of thinking about a problem. An algorithm provides a general process for solving a category of problems, and a Python program or script is created from that problem-solving work.

Use Algorithms as Plans

Definition

An algorithm is a general process for solving a category of problems.

An algorithm helps separate the solving idea from the final program. Before focusing on Python instructions, you can think about the general process that would solve the problem. That process can then guide the creation of a Python program or script. This way of thinking is useful because the goal is not merely to produce lines of code; the goal is to produce a solution to a problem.

Plan a Small Program

Worked example

Turning a Small Task into a Program Plan

Imagine that you want to create a small Python program for a task you have chosen yourself.

  1. 1
    State the task

    Describe what the program should solve before thinking about individual Python instructions.

  2. 2
    Try first

    Make your own attempt to work out the solution. This gives you a clearer understanding of what you know and where you need help.

  3. 3
    Ask a smart question

    If part of the task is unclear, ask about that specific difficulty instead of immediately asking someone else to solve the entire problem.

  4. 4
    Describe the algorithm

    Write down the general process that could solve this category of problem.

  5. 5
    Create the script

    Use the algorithm as a guide while creating the Python program or script.

  6. 6
    Split it if it grows

    If the program becomes large, divide it into smaller pieces so there is less to look at while solving a problem, fixing a bug, or adding a new feature.

Result

The finished program is connected to a deliberate problem-solving process instead of being an unexplained collection of instructions.

This example does not prescribe one universal algorithm for every task. It demonstrates how a learner can move from a problem to an attempted solution, a clearer question, an algorithm, and finally a Python program or script.

Control Complexity with Smaller Pieces

Large programs create a special problem: it becomes impossible to keep the entire program in your mind at the same time. The source material describes programs that may grow to millions of lines and explains why code should be easy to understand. Breaking a large program into multiple smaller pieces gives you less to look at when solving a problem, fixing a bug, or adding a new feature.

Before

One very large program with every part considered at once

More of the program must be considered at the same time.

After

A program divided into multiple smaller pieces

Less of the program needs to be considered for a particular task.

Key point

Breaking a program into smaller pieces is not only useful when first solving a problem. It also helps when fixing a bug or adding a new feature.

Mistakes to Avoid

  • Common mistake

    Looking for a solution before trying the problem yourself

    What it looks like

    Immediately copying a solution without first deciding how you would approach the task.

    Why it fails

    You lose an opportunity to become comfortable with Python and problem-solving.

    Do this instead

    Make a genuine attempt first, then ask a focused question about the part that remains unclear.

  • Common mistake

    Asking a vague question

    What it looks like

    Asking for the entire problem to be solved without identifying the difficulty.

    Why it fails

    The question does not show which part of the problem needs clarification.

    Do this instead

    Ask a smart question about the specific step or idea that is causing difficulty.

  • Common mistake

    Treating a large program as one indivisible object

    What it looks like

    Trying to keep every part of a very large program in mind while changing one feature.

    Why it fails

    As programs grow, it becomes increasingly difficult to keep the entire program in your mind at the same time.

    Do this instead

    Break the program into multiple smaller pieces.

  • Common mistake

    Focusing only on writing code

    What it looks like

    Starting with Python instructions without first considering the problem-solving process.

    Why it fails

    The program can become disconnected from a clear solution to the problem.

    Do this instead

    Think about the problem and its general solving process before creating the Python program or script.

Apply the Process

EASY

Choose a small program that you would like to create. Write down the problem it should solve, describe your first attempt, record one smart question you might ask, and outline the algorithm as a general process. Then decide whether the program would need to be divided into smaller pieces as it grows.

Hints
  • Keep the chosen task small enough to describe clearly.
  • Describe the solving process rather than writing Python code.
  • Think about what would become difficult if the program became much larger.

Remember the Method

  1. 1
    Creating a Python program or script is part of a broader problem-solving process.
  2. 2
    An algorithm is a general process for solving a category of problems.
  3. 3
    Try to solve a problem yourself before asking for help, and ask smart questions when help is needed.
  4. 4
    As programs become large, break them into smaller pieces so they are easier to understand, modify, and debug.
  5. 5
    Creating your own programs helps you become more comfortable with Python and problem-solving.

Key Takeaways

  • A Python program is the result of solving a problem, not merely writing instructions.
  • An algorithm describes a general process for solving a category of problems.
  • Independent effort followed by focused questions strengthens problem-solving practice.
  • Breaking large programs into smaller pieces makes problems, bugs, and new features easier to handle.

Related concepts

More concepts starting with I