PYTHON PROGRAMMING
Introduction to Problem Solving
PYTHON PROGRAMMING
Python Programming Unit 1
Unit-1 Department of CSE
Introduction to Problem Solving
[Link] Analysis Chart
[Link]
[Link]
[Link]
Python Programming Unit-1 Department of CSE
Algorithm
An Algorithm is a step by step by process to solve a
problem.
(OR)
An algorithm is well-defined computational procedure
that takes some value, or set of values, as input and
produces some value, or set of values, as output.
Python Programming Unit-1 Department of CSE
Features / Characteristics of Algorithm
1. Input
– An algorithm takes Zero or more quantities as input.
2. Output
– An algorithm must produce at least one output .
3. Definiteness
– Each instruction is clear and unambiguous.
4. Finiteness
– If we trace out the instructions of an algorithm, then for all cases, the algorithm terminates after a finite number of steps.
5. Effectiveness
– Every instruction must very basic so that it can be carried out, in principle, by a person using only pencil & paper.
Python Programming Unit-1 Department of CSE
Advantages of Algorithms
[Link] to understand.
[Link]-wise representation of a solution to a given
problem.
[Link] for the programmer to convert an algorithm into
an actual program.
Python Programming Unit-1 Department of CSE
Disadvantages of Algorithms
[Link] an algorithm is time-consuming
[Link] complex logic through algorithms can be
very difficult.
[Link] and Looping statements are difficult to show
in Algorithms.
Python Programming Unit-1 Department of CSE
Example:
Write an algorithm to perform addition of two numbers.
Python Programming Unit-1 Department of CSE
Example:
Write an algorithm to perform addition of two numbers.
Input: any 2 numbers
Python Programming Unit-1 Department of CSE
Example:
Write an algorithm to perform addition of two numbers.
Input: any 2 numbers
Output: sum of the 2 numbers
Python Programming Unit-1 Department of CSE
Example:
Write an algorithm to perform addition of two numbers.
Input: any 2 numbers
Output: sum of the 2 numbers
Algorithm:
Step-1: Start
Python Programming Unit-1 Department of CSE
Example:
Write an algorithm to perform addition of two numbers.
Input: any 2 numbers
Output: sum of the 2 numbers
Algorithm:
Step-1: Start
Step-2: Read a number into variable A
Python Programming Unit-1 Department of CSE
Example:
Write an algorithm to perform addition of two numbers.
Input: any 2 numbers
Output: sum of the 2 numbers
Algorithm:
Step-1: Start
Step-2: Read a number into variable A
Step-3: Read another number into variable B
Python Programming Unit-1 Department of CSE
Example:
Write an algorithm to perform addition of two numbers.
Input: any 2 numbers
Output: sum of the 2 numbers
Algorithm:
Step-1: Start
Step-2: Read a number into variable A
Step-3: Read another number into variable B
Step-4: Perform addition and store result in total (total = A + B)
Python Programming Unit-1 Department of CSE
Example:
Write an algorithm to perform addition of two numbers.
Input: any 2 numbers
Output: sum of the 2 numbers
Algorithm:
Step-1: Start
Step-2: Read a number into variable A
Step-3: Read another number into variable B
Step-4: Perform addition and store result in total (total = A + B)
Step-5: Display total value
Python Programming Unit-1 Department of CSE
Example:
Write an algorithm to perform addition of two numbers.
Input: any 2 numbers
Output: sum of the 2 numbers
Algorithm:
Step-1: Start
Step-2: Read a number into variable A
Step-3: Read another number into variable B
Step-4: Perform addition and store result in total (total = A + B)
Step-5: Display total value
Step-6: Stop
Python Programming Unit-1 Department of CSE
Thank You
PYTHON PROGRAMMING
Python Programming Unit 1
Unit-1 Department of CSE