CONTENTS

Chapter 1:Introduction to Python

1.1Introduction

1.2Features of Python

1.2.1Easy

1.2.2Type and Run

1.2.3Syntax

1.2.4Mixing

1.2.5Dynamic Typing

1.2.6Built in Object Types

1.2.7Numerous Libraries and Tools

1.2.8Portable

1.2.9Free

1.3The Paradigms

1.3.1Procedural

1.3.2Object-Oriented

1.3.3Functional

1.4Chronology and Uses

1.4.1Chronology

1.4.2Uses

1.5Installation of Anaconda

1.6Conclusion

Chapter 2:Python Objects

2.1Introduction

2.2Basic Data Types Revisited

2.2.1Fractions

2.3Strings

2.4Lists and Tuples

2.4.1List

2.4.2Tuples

2.4.3Features of Tuples

2.5Conclusion

Chapter 3:Conditional Statements

3.1Introduction

3.2if, if-else, and if-elif-else constructs

3.3The if-elif-else Ladder

3.4Logical Operators

3.5The Ternary Operator

3.6The get Construct

3.7Examples

3.8Conclusion

Chapter 4:Looping

4.1Introduction

4.2While

4.3Patterns

4.4Nesting and Applications of Loops in Lists

4.5Conclusion

Chapter 5:Functions

5.1Introduction

5.2Features of a Function

5.2.1Modular Programming

5.2.2Reusability of Code

5.2.3Manageability

5.3Basic Terminology

5.3.1Name of a Function

5.3.2Arguments

5.3.3Return Value

5.4Definition and Invocation

5.4.1Working

5.5Types of Function

5.5.1Advantage of Arguments

5.6Implementing Search

5.7Scope

5.8Recursion

5.8.1Rabbit Problem

5.8.2Disadvantages of Using Recursion

5.9Conclusion

Chapter 6:Iterations, Generators, and Comprehensions

6.1Introduction

6.2The Power of “For

6.3Iterators

6.4Defining an Iterable Object

6.5Generators

6.6Comprehensions

6.7Conclusion

Chapter 7:File Handling

7.1Introduction

7.2The File Handling Mechanism

7.3The Open Function and File Access Modes

7.4Python Functions for File Handling

7.4.1The Essential Ones

7.4.2The OS Methods

7.4.3Miscellaneous Functions and File Attributes

7.5Command Line Arguments

7.6Implementation and Illustrations

7.7Conclusion

Chapter 8:Strings

8.1Introduction

8.2The Use of “For” and “While

8.3String Operators

8.3.1The Concatenation Operator (+)

8.3.2The Replication Operator

8.3.3The Membership Operator

8.4Functions for String Handling

8.4.1len()

8.4.2Capitalize()

8.4.3find()

8.4.4count

8.4.5Endswith()

8.4.6Encode

8.4.7Decode

8.4.8Miscellaneous Functions

8.5Conclusion

Chapter 9:Introduction to Object Oriented Paradigm

9.1Introduction

9.2Creating New Types

9.3Attributes and Functions

9.3.1Attributes

9.3.2Functions

9.4Elements of Object-Oriented Programming

9.4.1Class

9.4.2Object

9.4.3Encapsulation

9.4.4Data Hiding

9.4.5Inheritance

9.4.6Polymorphism

9.4.7Reusability

9.5Conclusion

Chapter 10:Classes and Objects

10.1Introduction to Classes

10.2Defining a Class

10.3Creating an Object

10.4Scope of Data Members

10.5Nesting

10.6Constructor

10.7Constructor Overloading

10.8Destructors

10.9Conclusion

Chapter 11:Inheritance

11.1Introduction to Inheritance and Composition

11.1.1Inheritance and Methods

11.1.2Composition

11.2Inheritance: Importance and Types

11.2.1Need for Inheritance

11.2.2Types of Inheritance

11.3Methods

11.3.1Bound Methods

11.3.2Unbound Method

11.3.3Methods are Callable Objects

11.3.4The Importance and Usage of Super

11.3.5Calling the Base Class Function Using Super

11.4Search in Inheritance Tree

11.5Class Interface and Abstract Classes

11.6Conclusion

Chapter 12:Operator Overloading

12.1Introduction

12.2_init_ Revisited

12.2.1Overloading _init_ (sort of)

12.3Methods for Overloading Binary Operators

12.4Overloading Binary Operators: The Fraction Example

12.5Overloading the += Operator

12.6Overloading the > and < Operators

12.7Overloading the _boolEan_ Operators: Precedence of _bool_over _len_

12.8Destructors

12.9Conclusion

Chapter 13:Exception Handling

13.1Introduction

13.2Importance and Mechanism

13.2.1An Example of Try/Catch

13.2.2Manually Raising Exceptions

13.3Built-In Exceptions in Python

13.4The Process

13.4.1Exception Handling: Try/Except

13.4.2Raising Exceptions

13.5Crafting User Defined Exceptions

13.6An Example of Exception Handling

13.7Conclusion

Chapter 14:Introduction to Data Structures

14.1Introduction

14.2Abstract Data Type

14.3Algorithms

14.4Arrays

14.5Iterative and Recursive Algorithms

14.5.1Iterative Algorithms

14.5.2Recursive Algorithms

14.6Conclusion

Chapter 15:Stacks and Queues

15.1Introduction

15.2Stack

15.3Dynamic Implementation of Stacks

15.4Dynamic Implementation: Another Way

15.5Applications of Stacks

15.5.1Reversing a String

15.5.2Infix, Prefix, and Postfix Expressions

15.6Queue

15.7Conclusion

Chapter 16:Linked Lists

16.1Introduction

16.2Operations

16.3Implementing Stack Using a Linked List

16.4Queue Using a Linked List

16.5Conclusion

Chapter 17:Binary Search Trees

17.1Introduction

17.2Definition and Terminology

17.2.1Graphs: Definition and Representation

17.2.2Trees: Definition, Classification, and Representation

17.2.3Representation of a Binary Tree

17.2.4Tree Traversal: In-order, Pre-order, and Post-order

17.3Binary Search Tree

17.3.1Creation and Insertion

17.3.2Traversal

17.3.3Maximum and Minimum Elements

17.4Conclusion

Chapter 18:Introduction to NUMPY

18.1Introduction

18.2Introduction to NumPy and Creation of a Basic Array

18.3Functions for Generating Sequences

18.3.1arange()

18.3.2linspace()

18.3.3logspace()

18.4Aggregate Functions

18.5Broadcasting

18.6Structured Arrays

18.7Conclusion

Chapter 19:Introduction to MATPLOTLIB

19.1Introduction

19.2The Plot Function

19.3Subplots

19.43 Dimensional Plotting

19.5Conclusion

Chapter 20:Introduction to Image Processing

20.1Introduction

20.2Opening, Reading, and Writing an Image

20.2.1Opening an Image

20.2.2Reading

20.2.3Writing an Image to a File

20.2.4Displaying an Image

20.3The Contour Function

20.4Clipping

20.5Statistical Information of an Image

20.6Basic Transformation

20.6.1Translation

20.6.2Rotation

20.6.3Scaling

20.7Conclusion

Appendix A:Multithreading in Python

Appendix B:Regular Expressions

Appendix C:Exercises for Practice: Programming Questions

Appendix D:Problems for Practice: Multiple Choice Questions

Appendix E:Answer to the Multiple Choice Questions

Bibliography

Index