SlideShare a Scribd company logo
1 of 105
Download to read offline
INTRODUCTION –
Problem Solving
Techniques, Programming
Language - PYTHON
KIT-KalaignarKarunanidhi
Institute of Technology
INTRODUCTION
I. Introduction: Fundamentals of digital computers.
II. Problem Solving Techniques: Algorithm, Flow
Chart, Pseudo code, Program Control Structures,
Programming Paradigms.
III. Programming languages: Generations of
Programming Languages, Language Translators,
and Features of a Good Programming Languages.
2
II.Problem Solving Techniques
ALGORITHM
Definition
• Algorithm is defined as a step by step procedure
for solving any problem.
• It is also a precise rule (or set of rules) specifying
how to solve a problem.
• An algorithm is a sequence of finite instructions,
often used for calculation and data processing.
3
• After the preparation of a suitable plan
for developing the program by its logic.
• i.e., the correct sequence and procedure
of instructions required to carryout the
task, the algorithms is often used to refer
the logic of a program.
4
Representation of Algorithm
• Algorithm has a starting point and a final point. Between these two points
are the instructions that solve the problem.
• Algorithms often have steps that repeat or require decisions (such as logic
or comparison).
• Algorithms can be expressed in any language from natural languages (like
English, French, etc.) to programming languages (like Basic, Fortran,
python, etc..)
• Algorithm is the basis for most of the programs. Each rule in an algorithm
is written in a programming language. All these rules are collectively called
a Program.
5
Algorithm (Find the Area)
1. Start
2. Read the value of radius r
3. Calculate - Area=3.14*r*r
4. Print the Area of the circle
5. Stop
Now test the algorithm with sample data
Consider the value of radius r=5
Area=3.14*5*5 =78.5
6
Characteristic Of Algorithm
• Algorithm has a finite number of inputs.
• Every instruction should be precise and unambiguous.
• Ensure that the algorithm has proper termination.
• Effectiveness of each step is very important.
• The desired output must be obtained only after the
algorithm
• The algorithm should be written in sequence.
7
Qualities of an Algorithm
• Accuracy : Algorithm should provide accurate
result than others.
• Memory : It should require minimum
computer memory.
• Time : The time taken to execute any program
is considered as a main quality. Lesser the
time taken better the quality.
• Sequence : The procedure of an algorithm
must be in a sequential form.
8
BUILDING BLOCKS OF ALGORITHM
• Statements
1. Simple Statement
2. Compound Statement
• State
• Control flow
• Functions
9
Instruction/Statements
• In computer programming, a statement is the
smallest standalone element that expresses some
action to be carried out.
• It is an instruction written in a high-level language
that commands the computer to perform a specified
action.
• A statement may have internal components (e.g.,
expressions).
10
Simple statements
• assignment: A:= A + 5
• goto: goto next;
• return: return 5;
• call: function()
11
Compound statements
• block: begin ------- end
• do-loop: do -------- while (i < 10);
• for-loop: for (…)
• if-statement: if ----
• else----
• switch-statement: switch (c) { case ‘a’: alert(); break;
case ‘q’: quit(); break; }
• while-loop: while (…) DO -----
12
State
• An algorithm is deterministic automation for
accomplishing a goal which, given an initial
state, will terminate in a defined end-state.
• Data is read from an input source or device,
written to an output sink or device, and/or
stored for further processing.
13
Control flow
• The order function calls, instructions, and
statements are executed or evaluated when a
program is running.
1. Sequence Control Structure
2. Selection Control Structures
14
Sequence Control Structure
• The sequential control structure is used to
perform the actions one after another.
• It performs process A and then performs process
B and so on.
• This structure is represented by writing one
process after another.
• The logic flow is top to bottom approach.
15
Selection Control Structures
• Selection control structures (or) Decision
structures allows the program to make a choice
between two alternate paths whether it is true or
false.
• IF...THEN or IF..THEN..ELSE or a case structures are
the selection structures.
• This logic is used for making decisions.
16
Functions
• Functions are “self contained” modules of code that
accomplish a specific task.
• Functions usually “take in” data, process it, and “return” a
result.
• Once a function is written, it can be used over and over and
over again.
• Functions can be “called” from the inside of other functions.
17
Contin..
• When a function is “called” the program “leaves” the current section of
code and begins to execute the first line inside the function.
Thus the function “flow of control” is:
• The program comes to a line of code containing a “function call”.
• The program enters the function (starts at the first line in the function
code).
• All instructions inside of the function are executed from top to bottom.
• The program leaves the function and goes back to where it started from.
• Any data computed and RETURNED by the function is used in place of the
function in the original line of code.
18
Functions contain:
• Name - describes the purpose of the function. such as “compute
Average”, or just “average”.
• Inputs - called parameters (Formal/Actual parameters). Describe
what data is necessary for the function to work and gives each
piece of data a Symbolic Name for use in the function.
• Calculation - varies for each function
• Output - Usually one (but sometimes zero or sometimes many)
values that are calculated inside the function and “returned” via the
output variables.
19
Eg:1
def add(x,y):
sum=x+y
return sum
x=5
y=6
print(‘sum is’,add(x,y))
(OR)
a=10
b=20
def add(a,b):
return(a+b)
print('the addition of two nos is',add(a,b))
20
NOTATION
• PESUOCODE
• FLOWCHARTS
• PROGRAMMING LANGUAGE
22
• Pseudocode is a kind of structure english for
designing algorithm.
• Pseudocodes came from two words. Pseudo and
code pseudo means imitation and code refer to
instructions, written in a programming language.
• Pseudocode cannot be compiled nor executed, and
there are no real formatting or syntax rules
• The benefit of pseudo code is that it enables the
programmer to concentrate on the algorithms
without worrying about all the syntactic details of a
particular programming language.
23
Guidelines for Writing Pseudocode
• Write only one Statement per Line
• Capitalize initial keyword :
Few keywords we use:-
READ,WRITE,IF, ELSE, ENDIF, WHILE,
ENDWHILE, REPEAT, UNTIL
• Indent to show hierarchy :
Indentation is a process of showing
the boundaries of the structure.
24
Pseudocode is made up of the following logic
structure ,
• Sequential logic
• Selection logic
• Iteration logic
25
26
Sequence Logic :
• It is used to perform instructions in a sequence,that is one after another
• Thus,for sequence logic ,pseudocode instructions are written in an order
in which they are to be performed.
• The logic flow of pseudocode is from top to bottom.
Eg:1
A pseudocode to add two numbers and display the results:
READ num1, num2
result = num1 + num2
WRITE result.
 Sequence logic
27
Selection Logic
• It is used for making decisions and for
selecting the proper path out of two or
more alternative paths in program logic.
• It is also known as decision logic.
• Selection logic is depicted as either an
IF..THEN or an IF…THEN..ELSE Structure.
28
Eg.: Pseudocode greatest of two numbers
START
READ a and b
IF a>b THEN
PRINT “A is big”
ELSE
PRINT “B is big”
ENDIF
STOP
29
Repetition Logic
• It is used to produce loops when one or more
instructions may be executed several times
depending on some conditions .
• It uses structures called DO_WHILE,FOR and
REPEAT__UNTIL
30
Pseudocode to print first 10 natural numbers
START
INITIALIZE a = 0
WHILE a<10
PRINT a
a=a+1
ENDWHILE
STOP
31
Guess its Type!!!
Swapping using temporary variables.
READ the value of a, b
Interchange the values using a variable t
t = a
a = b
b = t
WRITE the swapped value of a, b
Stop
32
FLOWCHART
• A flow chart is a diagrammatic
representation, that illustrates the sequence
of operations to be performed to arrive at the
solution.
• Each step in the process is represented by a
different symbol and contains a short
description of the process step.
• The flow chart symbols are linked together
with arrows showing the flow direction of the
process.
33
34
GUIDELINES FOR DRAWING
FLOWCHARTS
35
36
Advantages of Flowcharts
• Communication
• Effective analysis
• Proper documentation
• Efficient Coding
• Proper Testing & Debugging
• Efficient Program Maintenance
37
Flowchart and Pseudocode is made up of the
following logic structure
• Sequential logic
• Selection logic
• Iteration logic
38
Sequence Logic
• In a computer program or an algorithm,
sequence involves simple steps which are to
be executed one after the other.
• The steps are executed in the same order in
which they are written.
39
Example 1
Sum of two numbers
40
Selection Logic
• Selection is used in a computer program or
algorithm to determine which particular
step or set of steps is to be executed. This is
also referred to as a ‘decision’.
• A selection statement can be used to
choose a specific path dependent on a
condition.
41
Find biggest among two numbers
42
Repetition Logic
• Repetition allows for a portion of an algorithm or
computer program to be executed any number of
times dependent on some condition being met.
• An occurrence of repetition is usually known as a
loop.
• The termination condition can be checked or
tested at the beginning or end of the loop, and is
known as a pre-test or post-test, respectively.
43
Pre test loop- Example Factorial
44
Post test loop- Eg print all natural
numbers
up to n
45
Algorithm,Flowchart,Pseudocode
Comparison
46
Few Examples
47
48
Find the area of a triangle.
49
50
Programming Paradigm
• A programming paradigm is a fundamental style of
computer programming, serving as a way of building the
structure and elements of computer programs.
• Comparing with a software development methodology,
it is a style of solving specific software engineering
problems.
51
History
• Different approaches to programming have developed
over time.
• The concept of a "programming paradigm" as such
dates at least to 1978.
• The lowest-level programming paradigms are machine
code.
• In the 1960s, assembly languages were developed
followed by development of procedural languages.
52
Why study so many
programming languages ?
• To Improve our ability to Develop Effective algorithms.
• To improve Use of Existing Programming Languages.
• To allow a better choice of Programming Language.
• To make it Easier to design a new language.
53
Imperative Programming (C)
Object-Oriented Programming (C++)
Logic/Declarative Programming (Prolog)
Functional/Applicative Programming (Lisp)
Programming Paradigm - Types
54
1. Procedural Programming
• Often thought as a synonym for imperative programming.
• Specifying the steps the program must take to reach the
desired state.
• Based upon the concept of the procedure call.
• Procedures, also known as routines, subroutines, methods,
or functions that contain a series of computational steps to
be carried out.
55
Contin.,
• The syntax of such languages generally has the form
statement 1;
statement 2;
--------------
statement n;
56
Contin.,
• The ability to re-use the same code at different
places in the program without copying it.
• The ability to be strongly modular or structured.
• Example of procedural programming are C,
Pascal, Basic, FORTRAN etc.
57
2. Functional Programming
• Functional programming is a programming
paradigm that treats computation as the
evaluation of mathematical functions and avoids
state changes and mutable data.
• Programs written using the functional
programming paradigm are much more easily
representable using mathematical concepts.
58
Contin.,
• The syntax of such languages is :
functionn { …function2 { function1 (data)} …}
• LISP was the first operational functional programming language.
• The Haskell programming language was released in the late 1980s
in an attempt to gather together many ideas in functional
programming research
59
Contin.,
• Not been very popular except for a restricted number of
application areas, such as artificial intelligence.
• Examples of Functional Programming are C, LISP, ML .
60
3.Logical Programming
• Also known as Rule based programming and
Declarative programming.
• Rule based programming checks for presence for a
certain condition and when present execute an
appropriate action
61
Contin.,
• The syntax of such Languages generally is similar to the
following.
enabling condition1→action1
enabling condition2→action2
..........................
enabling conditionn→actionn
62
4.Object Oriented Programming
• Object-oriented programming (OOP) is a
programming paradigm that uses "objects" – data
structures encapsulating data fields and procedures
together with their interactions – to design
applications and computer programs
• Programming techniques may include features such
as data abstraction, encapsulation, modularity,
polymorphism, and inheritance.
63
Contin.,
• Though it was invented with the creation of the Simula
language in 1965, and further developed in Smalltalk in the
1970s, it was not commonly used in mainstream software
application development until the early 1990s.
• Many modern programming languages now support OOP.
• Examples of Object oriented Programming are C++, java,
Smalltalk, simula etc.
64
III. Programming languages -
Generations of Programming
Languages
65
A programming language is a set of rules that provides
a way of telling a computer what operations to
perform.
A programming language is a set of rules for
communicating an algorithm
It provides a linguistic framework for
describing computations
66
A programming language is a notational system for
describing computation in a machine-readable and
human-readable form.
A programming language is a notational system for
describing computation in a machine-readable and
human-readable form.
67
A programming language is a tool for developing
executable models for a class of problem domains.
A programming language is a tool for developing
executable models for a class of problem domains.
• English is a natural language.
• It has words, symbols and grammatical rules.
• A programming language also has words,
symbols and rules of grammar.
• The grammatical rules are called syntax.
• Each programming language has a different set of
syntax rules.
68
Why does some people speak French?
Programming languages have evolved over time as
better ways have been developed to design them.
69
◦ First programming languages were developed in the
1950s
◦ Since then thousands of languages have been developed
Different programming languages are designed for
different types of programs.
High-level program
70
class Triangle {
...
float surface()
return b*h/2;
}
Low-level program LOAD r1,b
LOAD r2,h
MUL r1,r2
DIV r1,#2
RET
Executable Machine code 0001001001000101
0010010011101100
10101101001...
71
• First Generation Languages
•Second Generation Languages
•Third Generation Languages
•Fourth Generation Languages
•Fifth Generation Languages
72
Machine language
73
◦ Operation code – such as addition or subtraction.
◦ Operands – that identify the data to be processed.
◦ Machine language is machine dependent as it is the
only language the computer can understand.
◦ Very efficient code but very difficult to write.
Assembly languages
74
◦ Symbolic operation codes replaced binary operation
codes.
◦ Assembly language programs needed to be “assembled” for
execution by the computer.
◦ Each assembly language instruction is translated into one
machine language instruction.
◦ Very efficient code and easier to write.
 Closer to English but included simple mathematical
notation.
75
◦ Programs written in source code which must be translated
into machine language programs called object code.
◦ The translation of source code to object code is
accomplished by a machine language system program
called a compiler.
 Alternative to compilation is interpretation which is
accomplished by a system program called an
interpreter.
Common third generation languages
76
◦ FORTRAN
◦ COBOL
◦ C and C++
◦ Visual Basic
A high level language (4GL) that requires fewer
instructions to accomplish a task than a third
generation language.
Used with databases
77
◦ Query languages
◦ Report generators
◦ Forms designers
◦ Application generators
Declarative languages
78
Functional(?): Lisp, Scheme, SML
◦ Also called applicative
◦ Everything is a function
Logic: Prolog
◦ Based on mathematical logic
◦ Rule- or Constraint-based
79
Two broad groups
80
◦ Traditional programming languages
 Sequences of instructions
 First, second and some third generation languages
◦ Object-oriented languages
 Objects are created rather than sequences of instructions
 Some third generation, and fourth and fifth generation
languages
 FORTRAN
81
◦ FORmula TRANslation.
◦ Developed at IBM in the mid-1950s.
◦ Designed for scientific and mathematical applications by
scientists and engineers.
 COBOL
82
◦ COmmon Business Oriented Language.
◦ Developed in 1959.
◦ Designed to be common to many different computers.
◦ Typically used for business applications.
BASIC
83
◦ Beginner’s All-purpose Symbolic Instruction Code.
◦ Developed at Dartmouth College in mid 1960s.
◦ Developed as a simple language for students to write
programs with which they could interact through
terminals.
 C
◦ Developed by Bell Laboratories in the early 1970s.
◦ Provides control and efficiency of assembly language
while having third generation language features.
◦ Often used for system programs.
◦ UNIX is written in C.
84
 Simula
85
◦ First object-oriented language
◦ Developed by Ole Johan Dahl in the 1960s.
Smalltalk
◦ First purely object-oriented language.
◦ Developed by Xerox in mid-1970s.
◦ Still in use on some computers.
 C++
86
◦ It is C language with additional features.
◦ Widely used for developing system and application
software.
◦ Graphical user interfaces can be developed easily with
visual programming tools.
 JAVA
87
◦ An object-oriented language similar to C++ that
eliminates lots of C++’s problematic features
◦ Allows a web page developer to create programs for
applications, called applets that can be used through a
browser.
◦ Objective of JAVA developers is that it be machine,
platform and operating system independent.
Scripting Languages
88
◦ JavaScript and VBScript
◦ Php and ASP
◦ Perl and Python
Command Languages
◦ sh, csh, bash
Text processing Languages
◦ LaTex, PostScript
 HTML
89
◦ HyperText Markup Language.
◦ Used on the Internet and the World Wide Web (WWW).
◦ Web page developer puts brief codes called tags in the
page to indicate how the page should be formatted.
 XML
90
◦ Extensible Markup Language.
◦ A language for defining other languages.
Language Translators
92
93
94
95
96
97
98
99
100
101
Features of Good
programming
Formerly: Run Time Performance
(Computers were more expensive than programmers)
Now: Life cycle (human) cost is more important
Ease of designing,coding
Debugging
Maintenance
Reusability
103
Writability: The quality of a language that enables a
programmer to use it to express a computation clearly,
correctly, concisely, and quickly.
Readability: The quality of a language that enables a programmer
to understand and comprehend the nature of a computation
easily and accurately.
Orthogonality: The quality of a language that features
provided have as few restrictions as possible and be
combinable in any meaningful way.
Reliability: The quality of a language that assures a program will not
behave in unexpected or disastrous ways during execution.
Maintainability: The quality of a language that eases errors can be
found and corrected and new features added.
104
Generality: The quality of a language that avoids
special cases in the availability or use of constructs and
by combining closely related constructs into a single more general
one.
Uniformity: The quality of a language that similar features
should look similar and behave similar.
Extensibility:The quality of a language that provides
some general mechanism for the user to add new
constructs to a language.
Standardability: The quality of a language that allows
programs written to be transported from one computer to another
without significant change in language structure.
Implementability: The quality of a language that
provides a translator or interpreter can be written. This can
address to complexity of the language definition.
105
106

More Related Content

What's hot

Problem Solving and Python Programming
Problem Solving and Python ProgrammingProblem Solving and Python Programming
Problem Solving and Python ProgrammingMahaJeya
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and AlgorithmDhaval Kaneria
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming LanguageAhmad Idrees
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programmingManoj Tyagi
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programmingsavitamhaske
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
structured programming
structured programmingstructured programming
structured programmingAhmad54321
 
Conversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with StackConversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with Stacksahil kumar
 
Computer logic and gates
Computer logic and gatesComputer logic and gates
Computer logic and gatessamina khan
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming LanguageDr.YNM
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsMohamed Loey
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language Mohamed Loey
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An IntroductionSwarit Wadhe
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsJulie Iskander
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Languagesatvirsandhu9
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartRabin BK
 

What's hot (20)

Problem Solving and Python Programming
Problem Solving and Python ProgrammingProblem Solving and Python Programming
Problem Solving and Python Programming
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
structured programming
structured programmingstructured programming
structured programming
 
Conversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with StackConversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with Stack
 
Computer logic and gates
Computer logic and gatesComputer logic and gates
Computer logic and gates
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 
Digital Logic circuit
Digital Logic circuitDigital Logic circuit
Digital Logic circuit
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
 
Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Instruction format
Instruction formatInstruction format
Instruction format
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 

Similar to Introduction to Problem Solving Techniques- Python

Pseudo code.pptx
Pseudo code.pptxPseudo code.pptx
Pseudo code.pptxChaya64047
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptxTadiwaMawere
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem slovingMani Kandan
 
Basic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartBasic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartPrasanna R Kovath
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingSangheethaa Sukumaran
 
final Unit 1-1.pdf
final Unit 1-1.pdffinal Unit 1-1.pdf
final Unit 1-1.pdfprakashvs7
 
C program execution and algorithm
C program execution and algorithm C program execution and algorithm
C program execution and algorithm Kunal Pandhram
 
Computer programming and utilization
Computer programming and utilizationComputer programming and utilization
Computer programming and utilizationDigvijaysinh Gohil
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdfNayanChandak1
 
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptBCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptKirti Verma
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)praveena p
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Dr. Pankaj Agarwal
 
Lec-ProblemSolving.pptx
Lec-ProblemSolving.pptxLec-ProblemSolving.pptx
Lec-ProblemSolving.pptxmiansaad18
 
DG M 4 ppt.pptx
DG M 4 ppt.pptxDG M 4 ppt.pptx
DG M 4 ppt.pptxJumana74
 

Similar to Introduction to Problem Solving Techniques- Python (20)

Pseudo code.pptx
Pseudo code.pptxPseudo code.pptx
Pseudo code.pptx
 
Unit 1 psp
Unit 1 pspUnit 1 psp
Unit 1 psp
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
 
Plc part 3
Plc  part 3Plc  part 3
Plc part 3
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
 
L1
L1L1
L1
 
Basic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartBasic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chart
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
algorithm
algorithmalgorithm
algorithm
 
final Unit 1-1.pdf
final Unit 1-1.pdffinal Unit 1-1.pdf
final Unit 1-1.pdf
 
C program execution and algorithm
C program execution and algorithm C program execution and algorithm
C program execution and algorithm
 
Computer programming and utilization
Computer programming and utilizationComputer programming and utilization
Computer programming and utilization
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptBCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
 
lect 1-ds algo(final)_2.pdf
lect 1-ds  algo(final)_2.pdflect 1-ds  algo(final)_2.pdf
lect 1-ds algo(final)_2.pdf
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
 
Lec-ProblemSolving.pptx
Lec-ProblemSolving.pptxLec-ProblemSolving.pptx
Lec-ProblemSolving.pptx
 
UNIT-111.pptx
UNIT-111.pptxUNIT-111.pptx
UNIT-111.pptx
 
DG M 4 ppt.pptx
DG M 4 ppt.pptxDG M 4 ppt.pptx
DG M 4 ppt.pptx
 

Recently uploaded

main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 

Recently uploaded (20)

main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 

Introduction to Problem Solving Techniques- Python

  • 1. INTRODUCTION – Problem Solving Techniques, Programming Language - PYTHON KIT-KalaignarKarunanidhi Institute of Technology
  • 2. INTRODUCTION I. Introduction: Fundamentals of digital computers. II. Problem Solving Techniques: Algorithm, Flow Chart, Pseudo code, Program Control Structures, Programming Paradigms. III. Programming languages: Generations of Programming Languages, Language Translators, and Features of a Good Programming Languages. 2
  • 3. II.Problem Solving Techniques ALGORITHM Definition • Algorithm is defined as a step by step procedure for solving any problem. • It is also a precise rule (or set of rules) specifying how to solve a problem. • An algorithm is a sequence of finite instructions, often used for calculation and data processing. 3
  • 4. • After the preparation of a suitable plan for developing the program by its logic. • i.e., the correct sequence and procedure of instructions required to carryout the task, the algorithms is often used to refer the logic of a program. 4
  • 5. Representation of Algorithm • Algorithm has a starting point and a final point. Between these two points are the instructions that solve the problem. • Algorithms often have steps that repeat or require decisions (such as logic or comparison). • Algorithms can be expressed in any language from natural languages (like English, French, etc.) to programming languages (like Basic, Fortran, python, etc..) • Algorithm is the basis for most of the programs. Each rule in an algorithm is written in a programming language. All these rules are collectively called a Program. 5
  • 6. Algorithm (Find the Area) 1. Start 2. Read the value of radius r 3. Calculate - Area=3.14*r*r 4. Print the Area of the circle 5. Stop Now test the algorithm with sample data Consider the value of radius r=5 Area=3.14*5*5 =78.5 6
  • 7. Characteristic Of Algorithm • Algorithm has a finite number of inputs. • Every instruction should be precise and unambiguous. • Ensure that the algorithm has proper termination. • Effectiveness of each step is very important. • The desired output must be obtained only after the algorithm • The algorithm should be written in sequence. 7
  • 8. Qualities of an Algorithm • Accuracy : Algorithm should provide accurate result than others. • Memory : It should require minimum computer memory. • Time : The time taken to execute any program is considered as a main quality. Lesser the time taken better the quality. • Sequence : The procedure of an algorithm must be in a sequential form. 8
  • 9. BUILDING BLOCKS OF ALGORITHM • Statements 1. Simple Statement 2. Compound Statement • State • Control flow • Functions 9
  • 10. Instruction/Statements • In computer programming, a statement is the smallest standalone element that expresses some action to be carried out. • It is an instruction written in a high-level language that commands the computer to perform a specified action. • A statement may have internal components (e.g., expressions). 10
  • 11. Simple statements • assignment: A:= A + 5 • goto: goto next; • return: return 5; • call: function() 11
  • 12. Compound statements • block: begin ------- end • do-loop: do -------- while (i < 10); • for-loop: for (…) • if-statement: if ---- • else---- • switch-statement: switch (c) { case ‘a’: alert(); break; case ‘q’: quit(); break; } • while-loop: while (…) DO ----- 12
  • 13. State • An algorithm is deterministic automation for accomplishing a goal which, given an initial state, will terminate in a defined end-state. • Data is read from an input source or device, written to an output sink or device, and/or stored for further processing. 13
  • 14. Control flow • The order function calls, instructions, and statements are executed or evaluated when a program is running. 1. Sequence Control Structure 2. Selection Control Structures 14
  • 15. Sequence Control Structure • The sequential control structure is used to perform the actions one after another. • It performs process A and then performs process B and so on. • This structure is represented by writing one process after another. • The logic flow is top to bottom approach. 15
  • 16. Selection Control Structures • Selection control structures (or) Decision structures allows the program to make a choice between two alternate paths whether it is true or false. • IF...THEN or IF..THEN..ELSE or a case structures are the selection structures. • This logic is used for making decisions. 16
  • 17. Functions • Functions are “self contained” modules of code that accomplish a specific task. • Functions usually “take in” data, process it, and “return” a result. • Once a function is written, it can be used over and over and over again. • Functions can be “called” from the inside of other functions. 17
  • 18. Contin.. • When a function is “called” the program “leaves” the current section of code and begins to execute the first line inside the function. Thus the function “flow of control” is: • The program comes to a line of code containing a “function call”. • The program enters the function (starts at the first line in the function code). • All instructions inside of the function are executed from top to bottom. • The program leaves the function and goes back to where it started from. • Any data computed and RETURNED by the function is used in place of the function in the original line of code. 18
  • 19. Functions contain: • Name - describes the purpose of the function. such as “compute Average”, or just “average”. • Inputs - called parameters (Formal/Actual parameters). Describe what data is necessary for the function to work and gives each piece of data a Symbolic Name for use in the function. • Calculation - varies for each function • Output - Usually one (but sometimes zero or sometimes many) values that are calculated inside the function and “returned” via the output variables. 19
  • 20. Eg:1 def add(x,y): sum=x+y return sum x=5 y=6 print(‘sum is’,add(x,y)) (OR) a=10 b=20 def add(a,b): return(a+b) print('the addition of two nos is',add(a,b)) 20
  • 21. NOTATION • PESUOCODE • FLOWCHARTS • PROGRAMMING LANGUAGE 22
  • 22. • Pseudocode is a kind of structure english for designing algorithm. • Pseudocodes came from two words. Pseudo and code pseudo means imitation and code refer to instructions, written in a programming language. • Pseudocode cannot be compiled nor executed, and there are no real formatting or syntax rules • The benefit of pseudo code is that it enables the programmer to concentrate on the algorithms without worrying about all the syntactic details of a particular programming language. 23
  • 23. Guidelines for Writing Pseudocode • Write only one Statement per Line • Capitalize initial keyword : Few keywords we use:- READ,WRITE,IF, ELSE, ENDIF, WHILE, ENDWHILE, REPEAT, UNTIL • Indent to show hierarchy : Indentation is a process of showing the boundaries of the structure. 24
  • 24. Pseudocode is made up of the following logic structure , • Sequential logic • Selection logic • Iteration logic 25
  • 25. 26
  • 26. Sequence Logic : • It is used to perform instructions in a sequence,that is one after another • Thus,for sequence logic ,pseudocode instructions are written in an order in which they are to be performed. • The logic flow of pseudocode is from top to bottom. Eg:1 A pseudocode to add two numbers and display the results: READ num1, num2 result = num1 + num2 WRITE result.  Sequence logic 27
  • 27. Selection Logic • It is used for making decisions and for selecting the proper path out of two or more alternative paths in program logic. • It is also known as decision logic. • Selection logic is depicted as either an IF..THEN or an IF…THEN..ELSE Structure. 28
  • 28. Eg.: Pseudocode greatest of two numbers START READ a and b IF a>b THEN PRINT “A is big” ELSE PRINT “B is big” ENDIF STOP 29
  • 29. Repetition Logic • It is used to produce loops when one or more instructions may be executed several times depending on some conditions . • It uses structures called DO_WHILE,FOR and REPEAT__UNTIL 30
  • 30. Pseudocode to print first 10 natural numbers START INITIALIZE a = 0 WHILE a<10 PRINT a a=a+1 ENDWHILE STOP 31
  • 31. Guess its Type!!! Swapping using temporary variables. READ the value of a, b Interchange the values using a variable t t = a a = b b = t WRITE the swapped value of a, b Stop 32
  • 32. FLOWCHART • A flow chart is a diagrammatic representation, that illustrates the sequence of operations to be performed to arrive at the solution. • Each step in the process is represented by a different symbol and contains a short description of the process step. • The flow chart symbols are linked together with arrows showing the flow direction of the process. 33
  • 33. 34
  • 35. 36
  • 36. Advantages of Flowcharts • Communication • Effective analysis • Proper documentation • Efficient Coding • Proper Testing & Debugging • Efficient Program Maintenance 37
  • 37. Flowchart and Pseudocode is made up of the following logic structure • Sequential logic • Selection logic • Iteration logic 38
  • 38. Sequence Logic • In a computer program or an algorithm, sequence involves simple steps which are to be executed one after the other. • The steps are executed in the same order in which they are written. 39
  • 39. Example 1 Sum of two numbers 40
  • 40. Selection Logic • Selection is used in a computer program or algorithm to determine which particular step or set of steps is to be executed. This is also referred to as a ‘decision’. • A selection statement can be used to choose a specific path dependent on a condition. 41
  • 41. Find biggest among two numbers 42
  • 42. Repetition Logic • Repetition allows for a portion of an algorithm or computer program to be executed any number of times dependent on some condition being met. • An occurrence of repetition is usually known as a loop. • The termination condition can be checked or tested at the beginning or end of the loop, and is known as a pre-test or post-test, respectively. 43
  • 43. Pre test loop- Example Factorial 44
  • 44. Post test loop- Eg print all natural numbers up to n 45
  • 47. 48
  • 48. Find the area of a triangle. 49
  • 49. 50
  • 50. Programming Paradigm • A programming paradigm is a fundamental style of computer programming, serving as a way of building the structure and elements of computer programs. • Comparing with a software development methodology, it is a style of solving specific software engineering problems. 51
  • 51. History • Different approaches to programming have developed over time. • The concept of a "programming paradigm" as such dates at least to 1978. • The lowest-level programming paradigms are machine code. • In the 1960s, assembly languages were developed followed by development of procedural languages. 52
  • 52. Why study so many programming languages ? • To Improve our ability to Develop Effective algorithms. • To improve Use of Existing Programming Languages. • To allow a better choice of Programming Language. • To make it Easier to design a new language. 53
  • 53. Imperative Programming (C) Object-Oriented Programming (C++) Logic/Declarative Programming (Prolog) Functional/Applicative Programming (Lisp) Programming Paradigm - Types 54
  • 54. 1. Procedural Programming • Often thought as a synonym for imperative programming. • Specifying the steps the program must take to reach the desired state. • Based upon the concept of the procedure call. • Procedures, also known as routines, subroutines, methods, or functions that contain a series of computational steps to be carried out. 55
  • 55. Contin., • The syntax of such languages generally has the form statement 1; statement 2; -------------- statement n; 56
  • 56. Contin., • The ability to re-use the same code at different places in the program without copying it. • The ability to be strongly modular or structured. • Example of procedural programming are C, Pascal, Basic, FORTRAN etc. 57
  • 57. 2. Functional Programming • Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state changes and mutable data. • Programs written using the functional programming paradigm are much more easily representable using mathematical concepts. 58
  • 58. Contin., • The syntax of such languages is : functionn { …function2 { function1 (data)} …} • LISP was the first operational functional programming language. • The Haskell programming language was released in the late 1980s in an attempt to gather together many ideas in functional programming research 59
  • 59. Contin., • Not been very popular except for a restricted number of application areas, such as artificial intelligence. • Examples of Functional Programming are C, LISP, ML . 60
  • 60. 3.Logical Programming • Also known as Rule based programming and Declarative programming. • Rule based programming checks for presence for a certain condition and when present execute an appropriate action 61
  • 61. Contin., • The syntax of such Languages generally is similar to the following. enabling condition1→action1 enabling condition2→action2 .......................... enabling conditionn→actionn 62
  • 62. 4.Object Oriented Programming • Object-oriented programming (OOP) is a programming paradigm that uses "objects" – data structures encapsulating data fields and procedures together with their interactions – to design applications and computer programs • Programming techniques may include features such as data abstraction, encapsulation, modularity, polymorphism, and inheritance. 63
  • 63. Contin., • Though it was invented with the creation of the Simula language in 1965, and further developed in Smalltalk in the 1970s, it was not commonly used in mainstream software application development until the early 1990s. • Many modern programming languages now support OOP. • Examples of Object oriented Programming are C++, java, Smalltalk, simula etc. 64
  • 64. III. Programming languages - Generations of Programming Languages 65
  • 65. A programming language is a set of rules that provides a way of telling a computer what operations to perform. A programming language is a set of rules for communicating an algorithm It provides a linguistic framework for describing computations 66
  • 66. A programming language is a notational system for describing computation in a machine-readable and human-readable form. A programming language is a notational system for describing computation in a machine-readable and human-readable form. 67 A programming language is a tool for developing executable models for a class of problem domains. A programming language is a tool for developing executable models for a class of problem domains.
  • 67. • English is a natural language. • It has words, symbols and grammatical rules. • A programming language also has words, symbols and rules of grammar. • The grammatical rules are called syntax. • Each programming language has a different set of syntax rules. 68
  • 68. Why does some people speak French? Programming languages have evolved over time as better ways have been developed to design them. 69 ◦ First programming languages were developed in the 1950s ◦ Since then thousands of languages have been developed Different programming languages are designed for different types of programs.
  • 69. High-level program 70 class Triangle { ... float surface() return b*h/2; } Low-level program LOAD r1,b LOAD r2,h MUL r1,r2 DIV r1,#2 RET Executable Machine code 0001001001000101 0010010011101100 10101101001...
  • 70. 71
  • 71. • First Generation Languages •Second Generation Languages •Third Generation Languages •Fourth Generation Languages •Fifth Generation Languages 72
  • 72. Machine language 73 ◦ Operation code – such as addition or subtraction. ◦ Operands – that identify the data to be processed. ◦ Machine language is machine dependent as it is the only language the computer can understand. ◦ Very efficient code but very difficult to write.
  • 73. Assembly languages 74 ◦ Symbolic operation codes replaced binary operation codes. ◦ Assembly language programs needed to be “assembled” for execution by the computer. ◦ Each assembly language instruction is translated into one machine language instruction. ◦ Very efficient code and easier to write.
  • 74.  Closer to English but included simple mathematical notation. 75 ◦ Programs written in source code which must be translated into machine language programs called object code. ◦ The translation of source code to object code is accomplished by a machine language system program called a compiler.
  • 75.  Alternative to compilation is interpretation which is accomplished by a system program called an interpreter. Common third generation languages 76 ◦ FORTRAN ◦ COBOL ◦ C and C++ ◦ Visual Basic
  • 76. A high level language (4GL) that requires fewer instructions to accomplish a task than a third generation language. Used with databases 77 ◦ Query languages ◦ Report generators ◦ Forms designers ◦ Application generators
  • 77. Declarative languages 78 Functional(?): Lisp, Scheme, SML ◦ Also called applicative ◦ Everything is a function Logic: Prolog ◦ Based on mathematical logic ◦ Rule- or Constraint-based
  • 78. 79
  • 79. Two broad groups 80 ◦ Traditional programming languages  Sequences of instructions  First, second and some third generation languages ◦ Object-oriented languages  Objects are created rather than sequences of instructions  Some third generation, and fourth and fifth generation languages
  • 80.  FORTRAN 81 ◦ FORmula TRANslation. ◦ Developed at IBM in the mid-1950s. ◦ Designed for scientific and mathematical applications by scientists and engineers.
  • 81.  COBOL 82 ◦ COmmon Business Oriented Language. ◦ Developed in 1959. ◦ Designed to be common to many different computers. ◦ Typically used for business applications.
  • 82. BASIC 83 ◦ Beginner’s All-purpose Symbolic Instruction Code. ◦ Developed at Dartmouth College in mid 1960s. ◦ Developed as a simple language for students to write programs with which they could interact through terminals.
  • 83.  C ◦ Developed by Bell Laboratories in the early 1970s. ◦ Provides control and efficiency of assembly language while having third generation language features. ◦ Often used for system programs. ◦ UNIX is written in C. 84
  • 84.  Simula 85 ◦ First object-oriented language ◦ Developed by Ole Johan Dahl in the 1960s. Smalltalk ◦ First purely object-oriented language. ◦ Developed by Xerox in mid-1970s. ◦ Still in use on some computers.
  • 85.  C++ 86 ◦ It is C language with additional features. ◦ Widely used for developing system and application software. ◦ Graphical user interfaces can be developed easily with visual programming tools.
  • 86.  JAVA 87 ◦ An object-oriented language similar to C++ that eliminates lots of C++’s problematic features ◦ Allows a web page developer to create programs for applications, called applets that can be used through a browser. ◦ Objective of JAVA developers is that it be machine, platform and operating system independent.
  • 87. Scripting Languages 88 ◦ JavaScript and VBScript ◦ Php and ASP ◦ Perl and Python Command Languages ◦ sh, csh, bash Text processing Languages ◦ LaTex, PostScript
  • 88.  HTML 89 ◦ HyperText Markup Language. ◦ Used on the Internet and the World Wide Web (WWW). ◦ Web page developer puts brief codes called tags in the page to indicate how the page should be formatted.
  • 89.  XML 90 ◦ Extensible Markup Language. ◦ A language for defining other languages.
  • 91. 92
  • 92. 93
  • 93. 94
  • 94. 95
  • 95. 96
  • 96. 97
  • 97. 98
  • 98. 99
  • 99. 100
  • 100. 101
  • 102. Formerly: Run Time Performance (Computers were more expensive than programmers) Now: Life cycle (human) cost is more important Ease of designing,coding Debugging Maintenance Reusability 103
  • 103. Writability: The quality of a language that enables a programmer to use it to express a computation clearly, correctly, concisely, and quickly. Readability: The quality of a language that enables a programmer to understand and comprehend the nature of a computation easily and accurately. Orthogonality: The quality of a language that features provided have as few restrictions as possible and be combinable in any meaningful way. Reliability: The quality of a language that assures a program will not behave in unexpected or disastrous ways during execution. Maintainability: The quality of a language that eases errors can be found and corrected and new features added. 104
  • 104. Generality: The quality of a language that avoids special cases in the availability or use of constructs and by combining closely related constructs into a single more general one. Uniformity: The quality of a language that similar features should look similar and behave similar. Extensibility:The quality of a language that provides some general mechanism for the user to add new constructs to a language. Standardability: The quality of a language that allows programs written to be transported from one computer to another without significant change in language structure. Implementability: The quality of a language that provides a translator or interpreter can be written. This can address to complexity of the language definition. 105
  • 105. 106