Module 1 python.pptx

Dr. Jeetashree Aparajeeta
Assistant Professor (Sr)
SENSE
 Introduction to Problem Solving
◦ Problem Solving: Definition and Steps
◦ Problem Analysis Chart
◦ Developing an Algorithm
◦ Flowchart
◦ Pseudocode
2
 Use of computer technology help in completing any
task in a much faster and accurate manner.
 Ex. Paying electric bill, booking a health check up,
ordering your favorite food, booking movie tickets
etc.
 These technologies follow a proper problem
solving approach for an essential skill to solve the
related problems.
 Ex. You cannot order food using Apollo247 App.
3
 The standard computers, that we use, are not
advance enough to solve a problem of their own,
so we need to feed step-by-step instructions to
the computer to solve any problem.
 The efficiency in solving the problem depends
upon how correctly and precisely we define the
problem, design a solution (algorithm) and
implement the solution (program) using a
programming language.
4
 So, the problem solving can be defined as the
process of identifying a problem, developing an
algorithm for the identified problem and finally
implementing the algorithm to develop a
computer program.
5
 The correctness of the output that a computer gives
depends upon the correctness of input provided.
 Key steps required for solving a problem
I. Analyzing the problem
II. Developing an algorithm
a. Flowchart
b. Pseudocode
III. Coding
IV. Testing and Debugging
6
Module 1 python.pptx
Analysing the problem
It is important to clearly understand a problem before
we begin to find the solution for it. If we are not clear
as to what is to be solved, we may end up developing
a program which may not solve our purpose. Thus,
we need to read and analyse the problem statement
carefully in order to list the principal components of
the problem and decide the core functionalities that
our solution should have. By analysing a problem, we
would be able to figure out what are the inputs that
our program should accept and the outputs that it
should produce
4.2.1 Analysing the problem
It is important to clearly understand a problem before
we begin to find the solution for it. If we are not clear
as to what is to be solved, we may end up developing
a program which may not solve our purpose. Thus,
we need to read and analyse the problem statement
carefully in order to list the principal components of
the problem and decide the core functionalities that
our solution should have. By analysing a problem, we
would be able to figure out what are the inputs that
our program should accept and the outputs that it
should produce.
4.2.2 Developing an Algorithm
It is essential to device a solution before writing a
program code for a given problem. The solution is
represented in natural language and is called an
algorithm. We can imagine an algorithm like a very
well-written recipe for dish.
We start with a tentative solution plan and keep
on refining the algorithm until the algorithm is able
to capture all the aspects of the desired solution. For
a given problem, more than one algorithm is possible
and we have to select the most suitable solution
 4.2.3 Coding
 After finalising the algorithm, we need to
convert the algorithm into the format which
can be understood by the computer to
generate the desired solution. Different
 high level programming languages can be
used for writing a program
4.2.4 Testing and Debugging
The program created should be tested on
various parameters. The program should meet
the requirements of the user. It must respond
within the expected time. It should generate
correct output for all possible inputs. In the
presence of syntactical errors, no output will
be obtained. In case the output generated is
incorrect, then the program should be checked
for logical errors, if any.
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
Module 1 python.pptx
33
Separate the problem into
three components
Input
A list of data source
Provided to the problem
Output
A list of the output
required
Processing
A list of actions needed
to produce the required
outputs.
 PAC is used to analyze a problem.
 It has four sections:
a. The given data
b. The required result
c. The processing involved
d. A list of solution alternative
34
Given Data Required result
Section 1
Data given in the
problem/ provided by the
user
Section 2
Requirements for the
output reports including
the information needed
and the format required
Processing Required Solution Alternative
Section 3
List of processing
required including
equations or other types
of processing.
Section 4
List of ideas for the
solution of the problem
35
 Problem:
 A program is required to find average of five
numbers.
36
37
Given Data Required result
Number 1
Number 2
Number 3
Number 4
Number 5
Average of 5 numbers
Processing Required Solution Alternative
Total = Number 1 +
Number 2 + Number 3 +
Number 4 + Number 5
Average = Total / 5
i. Define the numbers as
constants
ii. Define the numbers as
input values
 Total = 5 + 6 + 8 + 9 + 11
Or
 Number 1 = 5, Number 2 = 6, Number 3 = 8,
Number 4 = 9, Number 5 = 11
Or
 Number = “Ask the user to provide the
number”
38
 Calculate the gross pay of an employee. The
formula to be used : GrossPay = Hours x
Payrate
39
40
Given Data Required result
Hours
PayRate
Gross Pay
Processing Required Solution Alternative
GrossPay = Hours * PayRate 1. Define the hours worked and
Payrate as constant
2. Define the hours worked and
PayRate as input
 Convert the distance in KM to miles where 1
mile = 1.609 km
41
42
Given Data Required result
Distance in km Distance in mile
Processing Required Solution Alternative
Mile = km/1.609 1. Define the km as constant
2. Define the km as input
 An algorithm is an effective method expressed as
a finite list of well defined instructions for
calculating a function, starting from an initial
state and initial input.
 The instructions describe a computation, which
will eventually produce output, when executed.
 Algorithm can be used to solve any kind of
problems.
 However, before writing a program, we need to
write the steps to solve the problem in simple
English language. This step-by-step procedure
to solve the problem is called algorithm.
43
 The way of execution of program is
categorized as
◦ Sequence Statements
◦ Selection Statements
◦ Iteration or Looping Statements (Called Control
Structure)
44
 In this program, all the instructions are
executed one after another.
 Ex: Algorithm to find the area of a rectangle
◦ Step 1: Start
◦ Step 2: Take length and breadth and store them as
L and B
◦ Step 3: Multiply by L and B and store it in Area
◦ Step 4: Print Area
◦ Step 5: Stop
45
 In this type of programming, some portion of
the program is executed based upon the
conditional test.
 If the conditional test is true, compiler will
execute some part of the program, otherwise
it will execute the other part of the program.
46
 Ex: Algorithm to check whether a candidate is
eligible to vote?
◦ Step 1: Start
◦ Step 2: Take age and store it in Age
◦ Step 3: Check Age value, if age > 18, then go to
step-4 else Step-5
◦ Step 4: Print “Eligible to Vote” and go to Step-6
◦ Step 5: Print “Not Eligible to Vote”
◦ Step 6: Stop
47
 Two common methods are used to represent
an algorithm
a. Flowchart
b. Pseudocode
 Either of the methods can be used to represent
an algorithm.
48
 The flowchart and pseudocode showcases the
logic of the solution required to solve the
problem excluding any implementation details.
 We can understand the flow of control during
execution of the program.
49
 Visual representation of an algorithm
 It is a diagram made up of boxes, diamonds
and other shapes, connected by arrows.
 Each shape represents a step of the solution
process and the arrow represents the order or
link among the steps.
50
A flow chart is an
organized
combination of shapes,
lines and text that
graphically illustrate a
process or structure.
51
 Write an algorithm to find the square of a
number
52
 Before developing the algorithm, first identify
the input, process and output.
◦ Input: Number whose square is required
◦ Process: Multiply the number by itself to get its
square
◦ Output: Square of the number
53
 Step 1: Input a number and stored it to Number
(Number is a variable)
 Step 2: Compute Number * Number and store it
in Square (Square is a variable)
 Step 3: Print Square
54
55
56
 Pseudocode is another way of representing an algorithm.
 It is a kind of structured English for describing algorithms
 It allows the designer to focus on the logic of the algorithm
without being distracted by details of language syntax
 Pseudocode needs to be complete
 It describe the entire logic of the algorithm so that
implementation becomes a rote mechanical task of
translating line by line into source code
57
 Each instruction is written on a separate line
 Keywords and indentation are used to signify
particular control structures
 Each set of instructions is written from top to
bottom, with only one entry and one exit
 Groups of statements may be formed into modules,
and that group given a name.
58
 Several keywords are often used to indicate
common input, output, and processing
operations
 Input: READ, OBTAIN, GET
 Output: PRINT, DISPLAY, SHOW
 Compute: COMPUTE, CALCULATE, DETERMINE
 Initialize: SET, INIT
 Add one: INCREMENT, BUMP, DECREMENT
59
 Area of Rectangle.
60
 READ height of Rectangle
 READ width of Rectangle
 COMPUTE area as height times width
 PRINT area of rectangle
61
Module 1 python.pptx
 Format
IF Condition THEN
Statements
ELSE
Statement
ENDIF
 Example
IF Hours_Worked > Normal_Max THEN
Display overtime message
ELSE
Display regular time message
ENDIF
63
 Format
WHILE Condition
Statements
ENDWHILE
 Example
WHILE Population < Limit
Compute Population as Population + Births ‐ Deaths
ENDWHILE
64
 Format
FOR Iteration Bounds
Statements
ENDFOR
 Example
FOR each student in the list
Print Register_Number
ENDFOR
65
Module 1 python.pptx
67
1 de 67

Recomendados

Unit 1 python (2021 r) por
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)praveena p
528 visualizações105 slides
Chapter 2(1) por
Chapter 2(1)Chapter 2(1)
Chapter 2(1)TejaswiB4
119 visualizações23 slides
Problem solving methodology por
Problem solving methodologyProblem solving methodology
Problem solving methodologyProf. Dr. K. Adisesha
867 visualizações12 slides
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES por
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHESC LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHESHarshJha34
955 visualizações62 slides
Algorithm.pdf por
Algorithm.pdfAlgorithm.pdf
Algorithm.pdfMIT,Imphal
76 visualizações26 slides
Introduction to Computer Programming por
Introduction to Computer ProgrammingIntroduction to Computer Programming
Introduction to Computer ProgrammingProf. Erwin Globio
2K visualizações6 slides

Mais conteúdo relacionado

Similar a Module 1 python.pptx

Algorithms notes 2 tutorials duniya por
Algorithms notes 2   tutorials duniyaAlgorithms notes 2   tutorials duniya
Algorithms notes 2 tutorials duniyaTutorialsDuniya.com
124 visualizações50 slides
C programming for Computing Techniques por
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing TechniquesAppili Vamsi Krishna
906 visualizações260 slides
Algorithm and its properties.pptx por
Algorithm and its properties.pptxAlgorithm and its properties.pptx
Algorithm and its properties.pptxMsAnita2
90 visualizações3 slides
Programming_Lecture_1.pptx por
Programming_Lecture_1.pptxProgramming_Lecture_1.pptx
Programming_Lecture_1.pptxshoaibkhan716300
30 visualizações54 slides
Unit 1-problem solving with algorithm por
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithmrajkumar1631010038
6.9K visualizações26 slides
C++ good tutorial por
C++ good tutorialC++ good tutorial
C++ good tutorialEzzat Atalla
5K visualizações214 slides

Similar a Module 1 python.pptx(20)

Algorithms notes 2 tutorials duniya por TutorialsDuniya.com
Algorithms notes 2   tutorials duniyaAlgorithms notes 2   tutorials duniya
Algorithms notes 2 tutorials duniya
TutorialsDuniya.com124 visualizações
C programming for Computing Techniques por Appili Vamsi Krishna
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
Appili Vamsi Krishna906 visualizações
Algorithm and its properties.pptx por MsAnita2
Algorithm and its properties.pptxAlgorithm and its properties.pptx
Algorithm and its properties.pptx
MsAnita290 visualizações
Programming_Lecture_1.pptx por shoaibkhan716300
Programming_Lecture_1.pptxProgramming_Lecture_1.pptx
Programming_Lecture_1.pptx
shoaibkhan71630030 visualizações
Unit 1-problem solving with algorithm por rajkumar1631010038
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
rajkumar16310100386.9K visualizações
C++ good tutorial por Ezzat Atalla
C++ good tutorialC++ good tutorial
C++ good tutorial
Ezzat Atalla5K visualizações
Ch1 principles of software development por Hattori Sidek
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software development
Hattori Sidek2K visualizações
Software develop.... por GCWUS
Software develop.... Software develop....
Software develop....
GCWUS412 visualizações
Program concep sequential statements por ankurkhanna
Program concep sequential statementsProgram concep sequential statements
Program concep sequential statements
ankurkhanna143 visualizações
Algorithmic problem sloving por Mani Kandan
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
Mani Kandan276 visualizações
AOA Week 01.ppt por INAM352782
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.ppt
INAM3527823 visualizações
Logic Development and Algorithm. por NandiniSidana
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.
NandiniSidana339 visualizações
What is algorithm por mshoaib15
What is algorithmWhat is algorithm
What is algorithm
mshoaib1580 visualizações
PCCF UNIT - 1 - M.Sudharsan.pptx por sudharsanm56
PCCF UNIT - 1 - M.Sudharsan.pptxPCCF UNIT - 1 - M.Sudharsan.pptx
PCCF UNIT - 1 - M.Sudharsan.pptx
sudharsanm562 visualizações
UNIT-2-PPTS-DAA.ppt por GovindUpadhyay25
UNIT-2-PPTS-DAA.pptUNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.ppt
GovindUpadhyay25118 visualizações
FIT-Unit3 chapter 1 -computer program por raksharao
FIT-Unit3 chapter 1 -computer programFIT-Unit3 chapter 1 -computer program
FIT-Unit3 chapter 1 -computer program
raksharao468 visualizações
Algorithm and flowchart por Sachin Goyani
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Sachin Goyani7.1K visualizações
Introduction to computer science por umardanjumamaiwada
Introduction to computer scienceIntroduction to computer science
Introduction to computer science
umardanjumamaiwada86 visualizações

Último

JQUERY.pdf por
JQUERY.pdfJQUERY.pdf
JQUERY.pdfArthyR3
107 visualizações22 slides
Mineral nutrition and Fertilizer use of Cashew por
 Mineral nutrition and Fertilizer use of Cashew Mineral nutrition and Fertilizer use of Cashew
Mineral nutrition and Fertilizer use of CashewAruna Srikantha Jayawardana
58 visualizações107 slides
Pharmaceutical Analysis PPT (BP 102T) por
Pharmaceutical Analysis PPT (BP 102T) Pharmaceutical Analysis PPT (BP 102T)
Pharmaceutical Analysis PPT (BP 102T) yakshpharmacy009
116 visualizações29 slides
UNIT NO 13 ORGANISMS AND POPULATION.pptx por
UNIT NO 13 ORGANISMS AND POPULATION.pptxUNIT NO 13 ORGANISMS AND POPULATION.pptx
UNIT NO 13 ORGANISMS AND POPULATION.pptxMadhuri Bhande
43 visualizações33 slides
Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37 por
Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37
Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37MysoreMuleSoftMeetup
54 visualizações17 slides
Thanksgiving!.pdf por
Thanksgiving!.pdfThanksgiving!.pdf
Thanksgiving!.pdfEnglishCEIPdeSigeiro
568 visualizações17 slides

Último(20)

JQUERY.pdf por ArthyR3
JQUERY.pdfJQUERY.pdf
JQUERY.pdf
ArthyR3107 visualizações
Pharmaceutical Analysis PPT (BP 102T) por yakshpharmacy009
Pharmaceutical Analysis PPT (BP 102T) Pharmaceutical Analysis PPT (BP 102T)
Pharmaceutical Analysis PPT (BP 102T)
yakshpharmacy009116 visualizações
UNIT NO 13 ORGANISMS AND POPULATION.pptx por Madhuri Bhande
UNIT NO 13 ORGANISMS AND POPULATION.pptxUNIT NO 13 ORGANISMS AND POPULATION.pptx
UNIT NO 13 ORGANISMS AND POPULATION.pptx
Madhuri Bhande43 visualizações
Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37 por MysoreMuleSoftMeetup
Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37
Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37
MysoreMuleSoftMeetup54 visualizações
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE... por Nguyen Thanh Tu Collection
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (FRIE...
Nguyen Thanh Tu Collection100 visualizações
11.30.23A Poverty and Inequality in America.pptx por mary850239
11.30.23A Poverty and Inequality in America.pptx11.30.23A Poverty and Inequality in America.pptx
11.30.23A Poverty and Inequality in America.pptx
mary850239181 visualizações
Artificial Intelligence and The Sustainable Development Goals (SDGs) Adoption... por BC Chew
Artificial Intelligence and The Sustainable Development Goals (SDGs) Adoption...Artificial Intelligence and The Sustainable Development Goals (SDGs) Adoption...
Artificial Intelligence and The Sustainable Development Goals (SDGs) Adoption...
BC Chew38 visualizações
DISTILLATION.pptx por Anupkumar Sharma
DISTILLATION.pptxDISTILLATION.pptx
DISTILLATION.pptx
Anupkumar Sharma75 visualizações
OOPs - JAVA Quick Reference.pdf por ArthyR3
OOPs - JAVA Quick Reference.pdfOOPs - JAVA Quick Reference.pdf
OOPs - JAVA Quick Reference.pdf
ArthyR364 visualizações
Meet the Bible por Steve Thomason
Meet the BibleMeet the Bible
Meet the Bible
Steve Thomason81 visualizações
Education of marginalized and socially disadvantages segments.pptx por GarimaBhati5
Education of marginalized and socially disadvantages segments.pptxEducation of marginalized and socially disadvantages segments.pptx
Education of marginalized and socially disadvantages segments.pptx
GarimaBhati547 visualizações
Guess Papers ADC 1, Karachi University por Khalid Aziz
Guess Papers ADC 1, Karachi UniversityGuess Papers ADC 1, Karachi University
Guess Papers ADC 1, Karachi University
Khalid Aziz105 visualizações
ANGULARJS.pdf por ArthyR3
ANGULARJS.pdfANGULARJS.pdf
ANGULARJS.pdf
ArthyR352 visualizações
What is Digital Transformation? por Mark Brown
What is Digital Transformation?What is Digital Transformation?
What is Digital Transformation?
Mark Brown41 visualizações
The Picture Of A Photograph por Evelyn Donaldson
The Picture Of A PhotographThe Picture Of A Photograph
The Picture Of A Photograph
Evelyn Donaldson37 visualizações
BUSINESS ETHICS MODULE 1 UNIT I_B.pdf por Dr Vijay Vishwakarma
BUSINESS ETHICS MODULE 1 UNIT I_B.pdfBUSINESS ETHICS MODULE 1 UNIT I_B.pdf
BUSINESS ETHICS MODULE 1 UNIT I_B.pdf
Dr Vijay Vishwakarma52 visualizações
JRN 362 - Lecture Twenty-Three (Epilogue) por Rich Hanley
JRN 362 - Lecture Twenty-Three (Epilogue)JRN 362 - Lecture Twenty-Three (Epilogue)
JRN 362 - Lecture Twenty-Three (Epilogue)
Rich Hanley43 visualizações

Module 1 python.pptx

  • 1. Dr. Jeetashree Aparajeeta Assistant Professor (Sr) SENSE
  • 2.  Introduction to Problem Solving ◦ Problem Solving: Definition and Steps ◦ Problem Analysis Chart ◦ Developing an Algorithm ◦ Flowchart ◦ Pseudocode 2
  • 3.  Use of computer technology help in completing any task in a much faster and accurate manner.  Ex. Paying electric bill, booking a health check up, ordering your favorite food, booking movie tickets etc.  These technologies follow a proper problem solving approach for an essential skill to solve the related problems.  Ex. You cannot order food using Apollo247 App. 3
  • 4.  The standard computers, that we use, are not advance enough to solve a problem of their own, so we need to feed step-by-step instructions to the computer to solve any problem.  The efficiency in solving the problem depends upon how correctly and precisely we define the problem, design a solution (algorithm) and implement the solution (program) using a programming language. 4
  • 5.  So, the problem solving can be defined as the process of identifying a problem, developing an algorithm for the identified problem and finally implementing the algorithm to develop a computer program. 5
  • 6.  The correctness of the output that a computer gives depends upon the correctness of input provided.  Key steps required for solving a problem I. Analyzing the problem II. Developing an algorithm a. Flowchart b. Pseudocode III. Coding IV. Testing and Debugging 6
  • 8. Analysing the problem It is important to clearly understand a problem before we begin to find the solution for it. If we are not clear as to what is to be solved, we may end up developing a program which may not solve our purpose. Thus, we need to read and analyse the problem statement carefully in order to list the principal components of the problem and decide the core functionalities that our solution should have. By analysing a problem, we would be able to figure out what are the inputs that our program should accept and the outputs that it should produce
  • 9. 4.2.1 Analysing the problem It is important to clearly understand a problem before we begin to find the solution for it. If we are not clear as to what is to be solved, we may end up developing a program which may not solve our purpose. Thus, we need to read and analyse the problem statement carefully in order to list the principal components of the problem and decide the core functionalities that our solution should have. By analysing a problem, we would be able to figure out what are the inputs that our program should accept and the outputs that it should produce.
  • 10. 4.2.2 Developing an Algorithm It is essential to device a solution before writing a program code for a given problem. The solution is represented in natural language and is called an algorithm. We can imagine an algorithm like a very well-written recipe for dish. We start with a tentative solution plan and keep on refining the algorithm until the algorithm is able to capture all the aspects of the desired solution. For a given problem, more than one algorithm is possible and we have to select the most suitable solution
  • 11.  4.2.3 Coding  After finalising the algorithm, we need to convert the algorithm into the format which can be understood by the computer to generate the desired solution. Different  high level programming languages can be used for writing a program
  • 12. 4.2.4 Testing and Debugging The program created should be tested on various parameters. The program should meet the requirements of the user. It must respond within the expected time. It should generate correct output for all possible inputs. In the presence of syntactical errors, no output will be obtained. In case the output generated is incorrect, then the program should be checked for logical errors, if any.
  • 33. 33 Separate the problem into three components Input A list of data source Provided to the problem Output A list of the output required Processing A list of actions needed to produce the required outputs.
  • 34.  PAC is used to analyze a problem.  It has four sections: a. The given data b. The required result c. The processing involved d. A list of solution alternative 34
  • 35. Given Data Required result Section 1 Data given in the problem/ provided by the user Section 2 Requirements for the output reports including the information needed and the format required Processing Required Solution Alternative Section 3 List of processing required including equations or other types of processing. Section 4 List of ideas for the solution of the problem 35
  • 36.  Problem:  A program is required to find average of five numbers. 36
  • 37. 37 Given Data Required result Number 1 Number 2 Number 3 Number 4 Number 5 Average of 5 numbers Processing Required Solution Alternative Total = Number 1 + Number 2 + Number 3 + Number 4 + Number 5 Average = Total / 5 i. Define the numbers as constants ii. Define the numbers as input values
  • 38.  Total = 5 + 6 + 8 + 9 + 11 Or  Number 1 = 5, Number 2 = 6, Number 3 = 8, Number 4 = 9, Number 5 = 11 Or  Number = “Ask the user to provide the number” 38
  • 39.  Calculate the gross pay of an employee. The formula to be used : GrossPay = Hours x Payrate 39
  • 40. 40 Given Data Required result Hours PayRate Gross Pay Processing Required Solution Alternative GrossPay = Hours * PayRate 1. Define the hours worked and Payrate as constant 2. Define the hours worked and PayRate as input
  • 41.  Convert the distance in KM to miles where 1 mile = 1.609 km 41
  • 42. 42 Given Data Required result Distance in km Distance in mile Processing Required Solution Alternative Mile = km/1.609 1. Define the km as constant 2. Define the km as input
  • 43.  An algorithm is an effective method expressed as a finite list of well defined instructions for calculating a function, starting from an initial state and initial input.  The instructions describe a computation, which will eventually produce output, when executed.  Algorithm can be used to solve any kind of problems.  However, before writing a program, we need to write the steps to solve the problem in simple English language. This step-by-step procedure to solve the problem is called algorithm. 43
  • 44.  The way of execution of program is categorized as ◦ Sequence Statements ◦ Selection Statements ◦ Iteration or Looping Statements (Called Control Structure) 44
  • 45.  In this program, all the instructions are executed one after another.  Ex: Algorithm to find the area of a rectangle ◦ Step 1: Start ◦ Step 2: Take length and breadth and store them as L and B ◦ Step 3: Multiply by L and B and store it in Area ◦ Step 4: Print Area ◦ Step 5: Stop 45
  • 46.  In this type of programming, some portion of the program is executed based upon the conditional test.  If the conditional test is true, compiler will execute some part of the program, otherwise it will execute the other part of the program. 46
  • 47.  Ex: Algorithm to check whether a candidate is eligible to vote? ◦ Step 1: Start ◦ Step 2: Take age and store it in Age ◦ Step 3: Check Age value, if age > 18, then go to step-4 else Step-5 ◦ Step 4: Print “Eligible to Vote” and go to Step-6 ◦ Step 5: Print “Not Eligible to Vote” ◦ Step 6: Stop 47
  • 48.  Two common methods are used to represent an algorithm a. Flowchart b. Pseudocode  Either of the methods can be used to represent an algorithm. 48
  • 49.  The flowchart and pseudocode showcases the logic of the solution required to solve the problem excluding any implementation details.  We can understand the flow of control during execution of the program. 49
  • 50.  Visual representation of an algorithm  It is a diagram made up of boxes, diamonds and other shapes, connected by arrows.  Each shape represents a step of the solution process and the arrow represents the order or link among the steps. 50
  • 51. A flow chart is an organized combination of shapes, lines and text that graphically illustrate a process or structure. 51
  • 52.  Write an algorithm to find the square of a number 52
  • 53.  Before developing the algorithm, first identify the input, process and output. ◦ Input: Number whose square is required ◦ Process: Multiply the number by itself to get its square ◦ Output: Square of the number 53
  • 54.  Step 1: Input a number and stored it to Number (Number is a variable)  Step 2: Compute Number * Number and store it in Square (Square is a variable)  Step 3: Print Square 54
  • 55. 55
  • 56. 56
  • 57.  Pseudocode is another way of representing an algorithm.  It is a kind of structured English for describing algorithms  It allows the designer to focus on the logic of the algorithm without being distracted by details of language syntax  Pseudocode needs to be complete  It describe the entire logic of the algorithm so that implementation becomes a rote mechanical task of translating line by line into source code 57
  • 58.  Each instruction is written on a separate line  Keywords and indentation are used to signify particular control structures  Each set of instructions is written from top to bottom, with only one entry and one exit  Groups of statements may be formed into modules, and that group given a name. 58
  • 59.  Several keywords are often used to indicate common input, output, and processing operations  Input: READ, OBTAIN, GET  Output: PRINT, DISPLAY, SHOW  Compute: COMPUTE, CALCULATE, DETERMINE  Initialize: SET, INIT  Add one: INCREMENT, BUMP, DECREMENT 59
  • 60.  Area of Rectangle. 60
  • 61.  READ height of Rectangle  READ width of Rectangle  COMPUTE area as height times width  PRINT area of rectangle 61
  • 63.  Format IF Condition THEN Statements ELSE Statement ENDIF  Example IF Hours_Worked > Normal_Max THEN Display overtime message ELSE Display regular time message ENDIF 63
  • 64.  Format WHILE Condition Statements ENDWHILE  Example WHILE Population < Limit Compute Population as Population + Births ‐ Deaths ENDWHILE 64
  • 65.  Format FOR Iteration Bounds Statements ENDFOR  Example FOR each student in the list Print Register_Number ENDFOR 65
  • 67. 67

Notas do Editor

  1. Flow Charts are used to help programmers during the early stages of programming. Flow Charts allow the programmer to set out, in a very simple way the sequence that he/she wants for each line of the program. A flow chart is an organized combination of shapes, lines and text that graphically illustrates a process or structure. Here's an example of how you could use shapes, lines, and text to build a chart: • The shapes (such as rectangles, circles, or diamonds) represent each step or decision point in the process. • The lines show the continuity of the process, demonstrating the paths the user should follow. • The text briefly describes each part of the process. A flow chart can be used for: (1) defining and analyzing processes (2) building a step-by-step picture of the process for analysis, discussion, or communication purposes (3) defining, standardizing, or finding areas for improvement in a process