1st Edition

Python for Engineers and Scientists Concepts and Applications

By Rakesh Nayak, Nishu Gupta Copyright 2023
    458 Pages 2 Color & 36 B/W Illustrations
    by CRC Press

    296 Pages 2 Color & 36 B/W Illustrations
    by CRC Press

    Also available as eBook on:

    The text focuses on the basics of Python programming fundamentals and introduction to present-day applications in technology and the upcoming state-of-art trends in a comprehensive manner. The text is based on Python 3.x and it covers the fundamentals of Python with object-oriented concepts having numerous worked-out examples. It provides a learning tool for the students of beginner level as well as for researchers of advanced level. Each chapter contains additional examples that explain the usage of methods/functions discussed in the chapter. It provides numerous programming examples along with their outputs.

    The book:

    • Includes programming tips to highlight the important concepts and help readers avoid common programming errors
    • Provides programming examples along with their outputs to ensure the correctness and help readers in mastering the art of writing efficient Python programs
    • Contains MCQs with their answers; conceptual questions and programming questions; and solutions to some selected programming questions, for every chapter
    • Discusses applications like time zone converter and password generators at the end
    • Covers fundamental of Python up to object oriented concepts including regular expression

    The book offers a simple and lucid treatment of concepts supported with illustrations for easy understanding, provides numerous programming examples along with their outputs, and includes programming tips to highlight the important concepts. It will be a valuable resource for senior undergraduate, graduate students, and professionals in the fields of electrical engineering, electronics and communication engineering, and computer engineering.

    Dedication
    Acknowledgements
    About the Authors
    Forewords
    Preface

    SECTION I: Python Fundamentals

    Chapter 1- Interaction with Python
    1.1 Introduction
    1.2. Variables and Identifiers
    1.2.1. How to Name Identifiers
    1.2.2. Use of Descriptive Identifiers and Comments
    1.2.3. Variable Types
    1.2.3.1. Numeric Data types
    1.2.3.2. None Data types
    1.2.3.3. Sequence Data types
    1.2.3.4. Set Data type
    1.2.3.5. Mapping Data type
    1.2.3.6. Array Datatype
    1.3. Constant
    1.4. Statement and Expression
    1.5. Input statements
    1.6. Output statements
    1.7. Formatting Output statements
    1.7.1. Escape Character
    1.7.2. sep and end
    1.7.3. String formatting with format()
    1.7.4. Numbers formatting with format()
    1.8. Comment Statement
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions


    Chapter 2- Operators
    2.1. Introduction
    2.2. Types of Operators
    2.2.1. Assignment Operator
    2.2.2. Arithmetic Operators
    2.2.2.1. Precedence of Arithmetic Operators
    2.2.3. Relational Operators
    2.2.4. Logical Operators
    2.2.4.1. and Operator
    2.2.4.2. or Operator
    2.2.4.3. not Operator
    2.2.5. Increment and Decrement Operators
    2.2.6. Bitwise Operators
      2.2.6.1. Bitwise AND operator (&)
      2.2.6.2. Bitwise OR operator (|)
      2.2.6.3. Bitwise XOR operator (^)
    2.2.6.4. Bitwise Complement (~)
    2.2.6.5. Bitwise Left Shift (<<)
    2.2.6.6. Bitwise Right Shift (>>)
    2.2.7. Membership Operators
    2.2.8. Identity Operators
    2.2.9. Precedence of all Operators
    2.3. Type Casting
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions


    Chapter 3 -Control Structures
    3.1. Introduction
    3.2. Conditionals
    3.2.1. Conditional if-else
    3.2.2. Conditional if-elif-else
    3.2.3. Nested if-elif-else statements.
    3.2.4. Ternary Operator
    3.3. Loops
    3.3.1. While Loop
    3.3.2. For Loop
    3.3.2.1. The range () function
    3.3.3. Continue, Break and Pass
     3.3.3.1. Continue Statement
     3.3.3.2. Break Statement
     3.3.3.3. Pass Statemtn
    3.3.4. Nested Loops
    3.4. Looping through two lists
    3.5. Iterator
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions


    Chapter 4 -String
    4.1. Introduction
    4.2. Strings
    4.2.1. Creating List
     4.2.1.1. Creating an Empty String
     4.2.1.2. Creating a sting from numbers
     4.2.1.3. Creating a string from list and Tuple
    4.2.2. Accessing String
    4.2.2.1. Membership in String
    4.2.3. String Operations
    4.2.3.1. Concatenation
    4.2.3.2. Repetition
    4.2.4. Character Encoding
    4.2.5. String Functions and Methods
    4.2.6. String Slicing
      4.2.6.1. String Slicing with Negative Index
      4.2.6.2. String Slicing with Step
      4.2.6.3. String Slicing Default Index
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions


    CHAPTER 5- List & Tuple
    5.1. Introduction
    5.2. List
    5.2.1. Creating List
     5.2.1.1. Creating an Empty list
     5.2.1.2. Creating a list from a string
     5.4.1.3. Creating a list by range function
     5.2.1.4. Creating a list from another list
    5.2.2. List Operations
    5.2.3. Accessing List
    5.2.3.1. Membership in List
     5.2.4. List Functions and Methods
    5.2.5. List Slicing
    5.2.5.1. List Slicing with Negative Index
    5.2.5.2. List Slicing with Step
    5.2.5.3. List Slicing Default Index
     5.2.6. Difference between Assignment and Copying a List
    5.3. Multi-Dimensional Lists
    5.3.1. Retrieval from Multidimensional list

    5.4. Tuples
    5.4.1. Creating Tuple
    5.4.1.1. Creating a tuple with no item
    5.4.1.2. Creating tuple with a single item
    5.4.1.3. Nesting tuples
    5.4.1.4. Creating Tuple from List
    5.4.1.5. Creating Tuple from String
    5.4.2. Tuple Operations
    5.4.2.1. Concatenation (+) Operation
    5.4.2.2. Repetition (*) Operation
    5.4.3. Tuple Assignment
     5.4.4. Accessing Tuple
    5.4.4.1. Membership in Tuple
    5.4.5. Updating Tuples
    5.4.6. Tuple Functions & Methods
    5.4.7. Tuple Slicing
    5.5. Advantages of Tuple over List
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions

     

    CHAPTER-6 Dictionary
    6.1. Introduction
    6.2. Dictionaries
    6.2.1. Creating Dictionary
    6.2.1.1. Creating a dictionary with no item
    6.2.1.2. Creating a dictionary with dict()
    6.2.1.3. Creating a default dictionary
    4.2.1.4. Creating a dictionary from list
    6.2.1.5. Insertion of a new key-value
    6.2.2. Dictionary Assignment
    6.2.3. Accessing Dictionary
    6.2.4. Dictionary Methods
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions


    CHAPTER-7 Set
    7.1. Introduction
    7.2. SET
    7.2.1. Creating Set
    7.2.1.1. Creating an Empty Set
    7.2.1.2. Creating a Set from a List, Tuples and String
    7.2.1.3. Creating a Set from a Dictionary
    7.2.2. Accessing Set elements
    7.2.3. Set Operations
    7.2.3. Set Functions and Methods
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions

     

    CHAPTER-8 Methods
    8.1. Introduction
    8.2. Functions
    8.3. Parameterized Function
    8.3.1. Positional and Keyword Parameters
    8.3.2. Default Parameter
    8.3.3. Function with Variable number of Arguments
    8.4. The Return Statement
    8.5. Namespace and Scope of a variable
    8.6. Recursive Function
    8.7. Lambda Function
    8.8. Generators
    8.9. Python Modules
    8.9.1. Importing a Module
    8.9.2. Aliasing
    8.9.3. User defined Module
    8.10. Closures
    8.11. Decorators
    8.11. 1. Passing parameter to Decorator
    8.11. 2. Decorator Chaining
    8.12. Some special methods and Attributes
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions

     

    CHAPTER-9 File Handling
    9.1. Introduction
    9.2. File IO
    9.2.1. File Opening and Closing
    9.2.2. File Properties
    9.2.3. File Reading
    9.2.4. File Writing
    9.2.5. Binary File Reading/Writing
    9.2.6.  CSV File Reading/Writing
    9.3. File Position
    9.4. Some more File operations
    9.5. Operating System related Operations
    9.6 The ‘with’ statement
    9.7 Pickling
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions

     

    SECTION II: Object Oriented Concepts in Python

    Chapter 10: Class and Objects
    10.1. Introduction to Object Oriented Programming
    10.2. Class and Object
     10.2.1 Defining a Class
     10.2.2 Generating an Object
    10.2.3. __init__, __new__, and __del__
     10.2.3.1 The __init__()
    10.2.3.2 The __new__()
    10.2.3.3 The __del__()
    10.3. Variables and Methods
    10.3.1. Variables
    10.3.1.1. Object Variables (Instance Variables)
    10.3.1.2. Class Variables (Static Variables)
     10.3.2. Accessing Variables
    10.4. Private and Public variables
    10.4.1. Variable starts without any _ symbol (No Underscore)
    10.4.2. Variable starting with _ symbol (single underscore)
    10.4.3. Variable starting with __ symbols (two underscore)
    10.5. Methods
    10.5.1. Instance Method
    10.5.2. Class Method
    10.5.3 Static Method
    10.6. Class inside a class (Inner Class)
    10.6.1. Accessing attributes of inner Class
    10.7. Some special methods
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions

     

    CHAPTER-11 Inheritance
    11.1. Introduction
    11.1.1.  Single Level inheritance
    11.1.2.  Multi-Level Inheritance
    11.1.3.  Multiple Inheritance
    11.1.4.  Hierarchical Inheritance
    11.1.5. Hybrid Inheritance
    11.2. Initialization in Inheritance
    11.2.1. __init__() for the child class only is defined
    11.2.2.__init__()  for the base class only is defined
    11.2.3.__init__() for both sub class and super class is defined
    11.3. Method Resolution order (MRO)
    11.4. Specialized Methods
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions

     

    CHAPTER-12 Polymorphism
    12.1. Introduction
    12.1.1. Duck-Typing
    12.1.2. Operator Overloading
    12.1.3.  Method Overloading
    12.1.4. Method Overriding
    12.2. Encapsulation
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions

     


    CHAPTER-13 Abstract Class, Aggregation, Composition
    13.1. Introduction- Abstract Class
    13.2. Abstract Class and Abstract Method
    13.3. Relationship
    13.3.1. Association Relationship
    13.3.2. Aggregation (uses a) relationship
    13.3.3. Composition (has a) relationship
    13.4. Difference between Inheritance and Association
    13.5. Difference between Aggregation and Composition
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions

     

    CHAPTER-14 Exception Handling
    14.1. Errors and Exceptions
    14.2. The try, except, else, finally Block
    14.2.1. The try, except Block
    14.2.2. The try, except, else Block
    14.2.3. The try, except, else, finally Block
    14.2.4. Mentioning the Error Description
    14.3. The Exception Hierarchy
    14.4. Exception in a Function
    14.5. The raised exception
    14.6. User Defined Exceptions
    14.7. Assertion
    Additional Examples
    Multiple Choice Questions
    Descriptive Questions
    Programming Questions
    Solutions to Multiple Choice Questions

    Biography

    Dr. Rakesh Nayak, author of two text books, is currently a professor in the Department of Computer Science and Engineering at O. P. Jindal University, Raigarh, Chhattisgarh, India. He earned his Master’s degree in Computer Applications from Indira Gandhi National Open University in the year 2007 and MTech in computer science and engineering from Acharya Nagarjuna University, Andhra Pradesh, India in 2010 and his PhD degree in Computer Science from Behrampur University, Odisha, India in 2013. Prior to joining the computer science department of O. P. Jindal University in January 2022, he worked in various capacities in different Engineering/MCA colleges. He has more than 22 years of teaching experience and has guided 11 MTech students. He has many publications in international journals to his credit.

    Dr. Nishu Gupta is a senior member, IEEE. He is a postdoctoral fellow in the Smart Wireless Systems (SWS) Research Group at Norwegian University of Science and Technology (NTNU), located in Gjøvik, Norway. Before this position, he was an assistant professor in the Electronics and Communication Engineering department, College of Engineering and Technology, SRM Institute of Science and Technology, Chennai, India. He earned his PhD degree from Motilal Nehru National Institute of Technology Allahabad, Prayagraj, India, which is an Institute of National Importance as declared by the Govt. of India. He has authored and edited several books with international publishers such as Taylor & Francis, Springer, Wiley, Scrivener, among others. Dr. Nishu is on the editorial board of various International reputed journals and transactions. Dr. Nishu serves as an active reviewer in various highly reputed journals such as IEEE Transactions on ITS, IEEE Access, IET Communications and many more. He is a recipient of the Best Paper Presentation Award during an International Conference at Nanyang Technological University, Singapore. His research interests include Autonomous Vehicles, Edge Computing, Augmented Intelligence, Internet of Things, Internet of Vehicles, Deep Learning, Machine Learning, Ad-Hoc Networks, Vehicular Communication, Driving Efficiency, Cognitive Computing, and Human-Machine Interaction.