Programming Process: Problem Def., Solution Planning, Coding, Testing, Documentation, Lecture notes of Computer science

An overview of the programming process, including defining the problem and planning the solution using flowcharts or pseudocode, coding and testing the program, documenting the program, and understanding algorithms with their characteristics. It also covers the first Python program.

Typology: Lecture notes

2020/2021

Uploaded on 05/16/2021

don-tharindu
don-tharindu 🇱🇰

1 / 19

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Programming
LESSON [02] PROGRAMMING PROCESS
Programming Process UNIT1 - PROGRAMMING 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Programming Process: Problem Def., Solution Planning, Coding, Testing, Documentation and more Lecture notes Computer science in PDF only on Docsity!

Programming

LESSON [02] – PROGRAMMING PROCESS

Lesson Outline

 Programming Process - Steps

 Defining the Problem & Planning the Solution

 Coding & Testing the Program

 Documenting the Program

 An Algorithm & it’s Characteristics

 Structured Programming

 First Python Program

IPO Model – Defining the Problem Defining the problem consists of:

 Identifying what you know (input- given data), and

 What you want to obtain (output- the result)

Planning the Solution Two common ways of planning the solution:

  1. Draw a flowchart - a flowchart is a pictorial representation of a step-by-step solution to a problem.
  2. Write a pseudocode - English-like nonstandard language that lets you state your solution. It is more precise than in plain English but less precise than a formal programming language.

Flowchart & Pseudocode - Example

Coding the Program During this stage you translate the logic expressed in Pseudocode into a Programming Code. Here you need to adhere to the language rules called “Syntax” Syntax – Is like grammar in English, it specify the correct way to write statements in the program. Editor – Programmers usually use a text editor (e.g. Notepad), which is somewhat like a word processing program, to create a file that contains the program.

Desk Checking - Example Following pseudocode is expected to find the sum of numbers from 1 to 5. Desk check this code and comment on its correctness. Count = 1 Sum = 0 While Count <= 5 ◦ Count = Count + 1 ◦ Sum = Sum + Count End While Output Sum Step Count <= 5 Count Sum Output Initial (^) 1 0 Iteration 1

Translating Source module – Original program, is called a source module. Object module – Once translated by a compiler is called object module. Load module – After prewritten programs are linked from a system library results in a load module.

An Algorithm

 Algorithm = Procedure = Blueprint = Recipe

 We've all seen food recipes - they list the ingredients needed and a set of steps for how to make the described meal. Well, an algorithm is just like that.  You can think of a programming algorithm as a recipe that describes the exact steps needed for the computer to solve a problem or reach a goal.  Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output.  Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language.

Characteristics of Algorithms

 Unambiguous − Algorithm should be clear and unambiguous. Each of its steps (or

phases), and their inputs/outputs should be clear and must lead to only one

meaning.

 Input − An algorithm should have 0 or more well-defined inputs.

 Output − An algorithm should have 1 or more well-defined outputs, and should

match the desired output.

 Finiteness − Algorithms must terminate after a finite number of steps.

 Feasibility − Should be feasible with the available resources.

 Independent − An algorithm should have step-by-step directions, which should be

independent of any programming code.

First Python Program Running the program interactively using Python interpreter

  1. Press windows key and type python
  2. Select Python 3.5 from the window and launch the interpreter (Python shell)
  3. Type the above program line-by-line which executes that line just as you press the enter key

Running Python as File Saving the Python program as a file and running on the Command Prompt

  1. Type the program on the Notepad or using any editor and save the file with “.py” extension (myfirst.py)
  2. Open the Command Prompt
  3. Set the PATH to the directory where Python was installed by the running the following command 4. set PATH = %path%;C:\windows\programs\python
  4. Change current directory to the directory where the Python program was saved 6. cd c:\users\dayan\documents\python
  5. Now run the Python program by type the following on the Command Prompt 8. python myfirst.py

SUMMARY Today we learnt  Programming Process - Steps  Defining the Problem & Planning the Solution  Coding & Testing the Program  Documenting the Program  An Algorithm & it’s Characteristics  Structured Programming  First Python Program