Thanks to visit codestin.com
Credit goes to www.slideshare.net

BY
DR.BELMER GLADSON.V M.E.,Ph.D.,
ASSOCIATE PROFESSOR
ADHI COLLEGE OF ENGINEERING AND TECHNOLOGY
CONTENTS
 INTRODUCTION
 PROBLEM SOLVING TECHNIQUES
 ALGORITHMIC STRATEGIES
 FUNCTIONS
 PYTHON – VARIABLES AND OPERATORS
 CONTROL STRUCTURES
 STRINGS AND STRING MANIPULATION
 LIST,TUPLES AND DICTIONARY
INTRODUCTION
 Python is a general-purpose interpreted, interactive,
object-oriented, and high-level programming
language.
 It was created by Guido van Rossum during 1985- 1990
Why to Learn Python?
 Python is a high-level, interpreted, interactive and
object-oriented scripting language.
 Designed- highly readable.
 Uses English Keywords frequently.
 To become a great Software Engineer – Web
Development Domain.
 Python is Interpreted
 Python is Interactive
 Python is Object-Oriented
 Python is a Beginner's Language
Applications of Python
 Easy-to-learn
 Easy-to-read
 Easy-to-maintain
 Interactive Mode
 Portable
 OpenSource
 Real Time Applications
 Bit Torrent file sharing
 Google search engine, YouTube
 Face book, Drop box
PROBLEM SOLVING TECHNIQUES
 Define the problem and creating number of solutions.
 Starts –Problem specification, Ends – Correct
Program.
PROBLEM SOLVING TECHNIQUES
• Set of techniques that helps in providing logic –solve
the problem.
1. Algorithms.
2. Flowcharts.
3. Pseudo codes.
4. Programs
ALGORITHM
 Sequence of instructions that describe a method.
Qualities of an Algorithm:
 Should be written in simple English
 Should be precise and unambiguous.
 Should not be repeated infinitely.
 should conclude after a finite number of steps.
 Should have an end point
 Derived results should be obtained only after the
algorithm terminates.
Example:
Addition of Two Numbers:
1.Start
2. Read the value of ‘a’
3. Read the value of ‘b’
4. Calculate sum=a+b
5. Print the sum of two number
6. Stop
Flowchart
---Graphical Representation of an Algorithm
Example:
Pseudocode
 Informal high-level description.
 Example:
 To find sum of two numbers
1.READ num1,num2
2.sum=num1+num2
3.PRINT sum
Program
 Program= Algorithm +Data
 Set of instruction, to the computer to solve a problem.
 Accept the data to perform computation.
ALGORITHMIC STRATEGIES
FUNCTIONS
 Block of organized, reusable code that is used to
perform a single, related action.
 Methods, sub-routines.
 Syntax
function_name(parameters)
function statements
end function
Algorithm for addition of two
numbers using function
 Main function()
Step 1: Start
Step 2:Call the function add()
Step 3: Stop
• Sub function add()
Step1:Functionstart
Step2:Geta,bValues
Step 3: add c=a+b
Step 4: Print c
Step 5: Return
VARIABLES:
 Store a value by assigning it to a name.
 It can be of any length. No space is allowed
 Assigning value to variable:
 >>>counter =45
print (counter)
 single value to several variables
a=b=c=100
 Multiple values to multiple variables
>>>a,b,c=2,4,"ram"
OPERATORS
 Constructs which can manipulate the value of operands.
expression 4 + 5 = 9
 Types of Operators
 Arithmetic Operators
 Comparison (Relational)Operators
 Assignment Operators
 Logical Operators
 Bitwise Operators
 Membership Operators
 Identity Operators
Arithmetic operators:
Comparison (Relational)Operators
Assignment Operators
Logical Operators:
Bitwise Operators:
Membership Operators:
CONTROL STRUCTURES
 Conditional Statements
Conditional if
Alternative if… else
Chained if…elif…else
Nested if….else
Conditional if
Alternative if… else
Chained if…elif…else
Example
Nested if….else
Example:
STRINGS AND STRING MANIPULATION
 Series or sequence of characters
 Strings are marked by quotes:
Single quotes(' ') E.g., 'This a string in single quotes'
Double quotes(" ") E.g., "'This a string in double quotes‘”
Triple quotes(""" """)E.g., """This is a paragraph. It is
made up of multiple lines and sentences.""“
 Strings are Immutable
Operations on string
Lists
 List is an ordered sequence of items
 square brackets[]
 Items in the lists can be of different datatypes
 Operations on list: Indexing, Slicing ,Concatenation
Repetitions, Updation, Insertion, Deletion
Operations on list
Tuple:
 A tuple is same as list
 Parentheses()
 A tuple is an immutable list
 Benefit of Tuple:
 Tuples are faster than lists.
 If the user wants to protect the data from accidental changes,
tuple can be used
Basic Operations:
Dictionaries
 Dictionaries are unorderedsets.
 curly brackets{}
 Dictionaries are accessed via keys
Operations:
PROBLEM SOLVING TECHNIQUES USING PYTHON.pptx

PROBLEM SOLVING TECHNIQUES USING PYTHON.pptx

  • 1.
    BY DR.BELMER GLADSON.V M.E.,Ph.D., ASSOCIATEPROFESSOR ADHI COLLEGE OF ENGINEERING AND TECHNOLOGY
  • 2.
    CONTENTS  INTRODUCTION  PROBLEMSOLVING TECHNIQUES  ALGORITHMIC STRATEGIES  FUNCTIONS  PYTHON – VARIABLES AND OPERATORS  CONTROL STRUCTURES  STRINGS AND STRING MANIPULATION  LIST,TUPLES AND DICTIONARY
  • 3.
    INTRODUCTION  Python isa general-purpose interpreted, interactive, object-oriented, and high-level programming language.  It was created by Guido van Rossum during 1985- 1990
  • 4.
    Why to LearnPython?  Python is a high-level, interpreted, interactive and object-oriented scripting language.  Designed- highly readable.  Uses English Keywords frequently.  To become a great Software Engineer – Web Development Domain.  Python is Interpreted  Python is Interactive  Python is Object-Oriented  Python is a Beginner's Language
  • 5.
    Applications of Python Easy-to-learn  Easy-to-read  Easy-to-maintain  Interactive Mode  Portable  OpenSource  Real Time Applications  Bit Torrent file sharing  Google search engine, YouTube  Face book, Drop box
  • 6.
    PROBLEM SOLVING TECHNIQUES Define the problem and creating number of solutions.  Starts –Problem specification, Ends – Correct Program. PROBLEM SOLVING TECHNIQUES • Set of techniques that helps in providing logic –solve the problem. 1. Algorithms. 2. Flowcharts. 3. Pseudo codes. 4. Programs
  • 7.
    ALGORITHM  Sequence ofinstructions that describe a method. Qualities of an Algorithm:  Should be written in simple English  Should be precise and unambiguous.  Should not be repeated infinitely.  should conclude after a finite number of steps.  Should have an end point  Derived results should be obtained only after the algorithm terminates.
  • 8.
    Example: Addition of TwoNumbers: 1.Start 2. Read the value of ‘a’ 3. Read the value of ‘b’ 4. Calculate sum=a+b 5. Print the sum of two number 6. Stop
  • 9.
  • 10.
  • 11.
    Pseudocode  Informal high-leveldescription.  Example:  To find sum of two numbers 1.READ num1,num2 2.sum=num1+num2 3.PRINT sum
  • 12.
    Program  Program= Algorithm+Data  Set of instruction, to the computer to solve a problem.  Accept the data to perform computation.
  • 13.
  • 14.
    FUNCTIONS  Block oforganized, reusable code that is used to perform a single, related action.  Methods, sub-routines.  Syntax function_name(parameters) function statements end function
  • 15.
    Algorithm for additionof two numbers using function  Main function() Step 1: Start Step 2:Call the function add() Step 3: Stop • Sub function add() Step1:Functionstart Step2:Geta,bValues Step 3: add c=a+b Step 4: Print c Step 5: Return
  • 16.
    VARIABLES:  Store avalue by assigning it to a name.  It can be of any length. No space is allowed  Assigning value to variable:  >>>counter =45 print (counter)  single value to several variables a=b=c=100  Multiple values to multiple variables >>>a,b,c=2,4,"ram"
  • 17.
    OPERATORS  Constructs whichcan manipulate the value of operands. expression 4 + 5 = 9  Types of Operators  Arithmetic Operators  Comparison (Relational)Operators  Assignment Operators  Logical Operators  Bitwise Operators  Membership Operators  Identity Operators
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
    CONTROL STRUCTURES  ConditionalStatements Conditional if Alternative if… else Chained if…elif…else Nested if….else
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
    STRINGS AND STRINGMANIPULATION  Series or sequence of characters  Strings are marked by quotes: Single quotes(' ') E.g., 'This a string in single quotes' Double quotes(" ") E.g., "'This a string in double quotes‘” Triple quotes(""" """)E.g., """This is a paragraph. It is made up of multiple lines and sentences.""“  Strings are Immutable
  • 32.
  • 33.
    Lists  List isan ordered sequence of items  square brackets[]  Items in the lists can be of different datatypes  Operations on list: Indexing, Slicing ,Concatenation Repetitions, Updation, Insertion, Deletion
  • 34.
  • 35.
    Tuple:  A tupleis same as list  Parentheses()  A tuple is an immutable list  Benefit of Tuple:  Tuples are faster than lists.  If the user wants to protect the data from accidental changes, tuple can be used
  • 36.
  • 37.
    Dictionaries  Dictionaries areunorderedsets.  curly brackets{}  Dictionaries are accessed via keys
  • 38.