This handbook provides a hands-on experience based on the underlying topics, and assists students and faculty members in developing their algorithmic thought process and programs for given computational problems. It can also be used by professionals who possess the necessary theoretical and computational thinking background but are presently making their transition to Python.
Key Features:
• Discusses concepts such as basic programming principles, OOP principles, database programming, GUI programming, application development, data analytics and visualization, statistical analysis, virtual reality, data structures and algorithms, machine learning, and deep learning.
• Provides the code and the output for all the concepts discussed.
• Includes a case study at the end of each chapter.
This handbook will benefit students of computer science, information systems, and information technology, or anyone who is involved in computer programming (entry-to-intermediate level), data analytics, HCI-GUI, and related disciplines.
Author(s): Dimitrios Xanthidis, Christos Manolas, Han-I Wang, Ourania K. Xanthidou
Publisher: CRC Press/Chapman & Hall
Year: 2022
Language: English
Pages: 629
City: Boca Raton
Cover
Half Title
Title Page
Copyright Page
Table of Contents
Editors
Contributors
Chapter 1 Introduction
1.1 Introduction
1.2 Audience
1.3 Getting Started with Jupyter Notebook
1.4 Creating Standalone, Executable Files
1.5 Structure of this Book
References
Chapter 2 Introduction to Programming with Python
2.1 Introduction
2.2 Algorithm vs. Program
2.2.1 Algorithm
2.2.2 Program
2.3 Lexical Structure
2.3.1 Case Sensitivity and Whitespace
2.3.2 Comments
2.3.3 Keywords
2.4 Punctuations and Variables
2.4.1 Punctuations
2.4.2 Variables
2.5 Data Types
2.5.1 Primitive Data Types
2.5.2 Non-Primitive Data Types
2.5.3 Examples of Variables and Data Types Using Python Code
2.6 Statements, Expressions, and Operators
2.6.1 Statements and Expressions
2.6.2 Operators
2.6.2.1 Arithmetic Operators
2.6.2.2 Comparison Operators
2.6.2.3 Logical Operators
2.6.2.4 Assignment Operators
2.6.2.5 Bitwise Operators
2.6.2.6 Operators Precedence
2.7 Sequence: Input and Output Statements
2.8 Selection Structure
2.8.1 The if Structure
2.8.2 The if… else Structure
2.8.3 The if… elif… else Structure
2.8.4 Switch Case Structures
2.8.5 Conditional Expressions
2.8.6 Nested if Statements
2.9 Iteration Statements
2.9.1 The while Loop
2.9.2 The for Loop
2.9.3 The Nested for Loop
2.9.4 The break and continue Statement
2.9.5 Using Loops with the Turtle Library
2.10 Functions
2.10.1 Function Definition
2.10.2 No Arguments, No Return
2.10.3 With Arguments, No Return
2.10.4 No Arguments, With Return
2.10.5 With Arguments, With Return
2.10.6 Function Parameter Passing
2.10.6.1 Call/Pass by Value
2.10.6.2 Call/Pass by Reference
2.11 Case Study
2.12 Exercises
2.12.1 Sequence and Selection
2.12.2 Iterations – while Loops
2.12.3 Iterations – for Loops
2.12.4 Methods
References
Chapter 3 Object-Oriented Programming in Python
3.1 Introduction
3.2 Classes and Objects in Python
3.2.1 Instantiating Objects
3.2.2 Object Data (Attributes)
3.2.2.1 Instance Attributes
3.2.2.2 Class Attributes
3.2.3 Object Behavior (Methods)
3.2.3.1 Instance Methods
3.2.3.2 Constructor Methods
3.2.3.3 Destructor Method
3.3 Encapsulation
3.3.1 Access Modifiers in Python
3.3.2 Getters and Setters
3.3.3 Validating Inputs before Setting
3.3.4 Creating Read-Only Attributes
3.3.5 The property() Method
3.3.6 The @property Decorator
3.4 Inheritance
3.4.1 Inheritance in Python
3.4.1.1 Customizing the Sub Class
3.4.2 Method Overriding
3.4.2.1 Overriding the Constructor Method
3.4.3 Multiple Inheritance
3.5 Polymorphism – Method Overloading
3.5.1 Method Overloading through Optional Parameters in Python
3.6 Overloading Operators
3.6.1 Overloading Built-In Methods
3.7 Abstract Classes and Interfaces in Python
3.7.1 Interfaces
3.8 Modules and Packages in Python
3.8.1 The import Statement
3.8.2 The from…import Statement
3.8.3 Packages
3.8.4 Using Modules to Store Abstract Classes
3.9 Exception Handling
3.9.1 Handling Exceptions in Python
3.9.1.1 Handling Specific Exceptions
3.9.2 Raising Exceptions
3.9.3 User-Defined Exceptions in Python
3.10 Case Study
3.11 Exercises
Chapter 4 Graphical User Interface Programming with Python
4.1 Introduction
4.1.1 Python's GUI Modules
4.1.2 Python IDE (Anaconda) and Chapter Scope
4.2 Basic Widgets in Tkinter
4.2.1 Empty Frame
4.2.2 The Label Widget
4.2.3 The Button Widget
4.2.4 The Entry Widget
4.2.5 Integrating the Basic Widgets
4.3 Enhancing the GUI Experience
4.3.1 The Spinbox and Scale Widgets inside Individual Frames
4.3.2 The Listbox and Combobox Widgets inside LabelFrames
4.3.3 GUIs with CheckButtons, RadioButtons and SimpleMessages
4.4 Basic Automation and User Input Control
4.4.1 Traffic Lights Version 1 – Basic Functionality
4.4.2 Traffic Lights Version 2 – Creating a Basic Illusion
4.4.3 Traffic Lights Version 3 – Creating a Primitive Automation
4.4.4 Traffic Lights Version 4 – A Primitive Screen Saver with a Progress Bar
4.4.5 Traffic Lights Version 5 – Suggesting a Primitive Screen Saver
4.5 Case Studies
4.6 Exercises
Chapter 5 Application Development with Python
5.1 Introduction
5.2 Messages, Common Dialogs, and Splash Screens in Python
5.2.1 Simple Message Boxes
5.2.2 Message Boxes with Options
5.2.3 Message Boxes with User Input
5.2.4 Splash Screen/About Forms
5.2.5 Common Dialogs
5.3 Menus
5.3.1 Simple Menus with Shortcuts
5.3.2 Toolbar Menus with Tooltips
5.3.3 Popup Menus with Embedded Icons
5.4 Enhancing the GUI Experience
5.4.1 Notebooks and Tabbed Interfaces
5.4.2 Threaded Applications
5.4.3 Combining Multiple Concepts and Applications in a Multithreaded System
5.5 Wrap Up
5.6 Case Study
Chapter 6 Data Structures and Algorithms with Python
6.1 Introduction
6.2 Lists, Tuples, Sets, Dictionaries
6.2.1 List
6.2.2 Tuple
6.2.3 Sets
6.2.4 Dictionary
6.3 Basic Sorting
6.3.1 Bubble Sort
6.3.2 Insertion Sort
6.3.3 Selection Sort
6.3.4 Shell Sort
6.3.5 Shaker Sort
6.4 Recursion, Binary Search, and Efficient Sorting with Lists
6.4.1 Recursion
6.4.2 Binary Search
6.4.3 Quicksort
6.4.4 Merge Sort
6.5 Complex Data Structures
6.5.1 Stack
6.5.2 Infix, Postfix, Prefix
6.5.3 Queue
6.5.4 Circular Queue
6.6 Dynamic Data Structures
6.6.1 Linked Lists
6.6.2 Binary Trees
6.6.3 Binary Search Tree
6.6.4 Graphs
6.6.5 Implementing Graphs and the Eulerian Path in Python
6.7 Wrap Up
6.8 Case Studies
6.9 Exercises
References
Chapter 7 Database Programming with Python
7.1 Introduction
7.2 Scripting for Data Definition Language
7.2.1 Creating a New Database in MySQL
7.2.2 Connecting to a Database
7.2.3 Creating Tables
7.2.4 Altering Tables
7.2.5 Dropping Tables
7.2.6 The DESC Statement
7.3 Scripting for Data Manipulation Language
7.3.1 Inserting Records
7.3.2 Updating Records
7.3.3 Deleting Records
7.4 Querying a Database and Using a GUI
7.4.1 The SELECT Statement
7.4.2 The SELECT Statement with a Simple Condition
7.4.3 The SELECT Statement Using GUI
7.5 Case Study
7.6 Exercises
References
Chapter 8 Data Analytics and Data Visualization with Python
8.1 Introduction
8.2 Importing and Cleaning Data
8.2.1 Data Acquisition: Importing and Viewing Datasets
8.2.2 Data Cleaning: Delete Empty or NaN Values
8.2.3 Data Cleaning: Fill Empty or NaN Values
8.2.4 Data Cleaning: Rename Columns
8.2.5 Data Cleaning: Changing and Resetting the Index
8.3 Data Exploration
8.3.1 Data Exploration: Counting and Selecting Columns
8.3.2 Data Exploration: Limiting/Slicing Dataset Views
8.3.3 Data Exploration: Conditioning/Filtering
8.3.4 Data Exploration: Creating New Data
8.3.5 Data Exploration: Grouping and Sorting Data
8.4 Descriptive Statistics
8.4.1 Measures of Central Tendency
8.4.2 Measures of Spread
8.4.3 Skewness and Kurtosis
8.4.4 The describe() and count() Methods
8.5 Data Visualization
8.5.1 Continuous Data: Histograms
8.5.2 Continuous Data: Box and Whisker Plot
8.5.3 Continuous Data: Line Chart
8.5.4 Categorical Data: Bar Chart
8.5.5 Categorical Data: Pie Chart
8.5.6 Paired Data: Scatter Plot
8.6 Wrapping Up
8.7 Case Study
References
Chapter 9 Statistical Analysis with Python
9.1 Introduction
9.1.1 What is Statistics?
9.1.2 Why Use Python for Statistical Analysis?
9.1.3 Overview of Available Libraries
9.2 Basic Statistics Concepts
9.2.1 Population vs. Sample: From Description to Inferential Statistics
9.2.2 Hypotheses and Statistical Significance
9.2.3 Confidence Intervals
9.3 Key Considerations Prior to Conducting Statistical Analysis
9.3.1 Level of Measures: Categorical and Numerical Variables
9.3.2 Types of Variables: Dependent and Independent Variables
9.3.3 Statistical Analysis Types and Hypothesis Tests
9.3.3.1 Statistical Analysis for Summary Investigative Questions
9.3.3.2 Statistical Analysis for Comparison Investigative Questions
9.3.3.3 Statistical Analysis for Relationship Investigative Questions
9.3.4 Choosing the Right Type of Statistical Analysis
9.4 Setting Up the Python Environment
9.4.1 Installing Anaconda and Launching the Jupyter Notebook
9.4.2 Installing and Running the Pandas Library
9.4.3 Review of Basic Data Analytics
9.5 Statistical Analysis Tasks
9.5.1 Descriptive Statistics
9.5.2 Comparison: The Mann-Whitney U Test
9.5.3 Comparison: The Wilcoxon Signed-Rank Test
9.5.4 Comparison: The Kruskal-Wallis Test
9.5.5 Comparison: Paired t-test
9.5.6 Comparison: Independent or Student t-Test
9.5.7 Comparison: ANOVA
9.5.8 Comparison: Chi-Square
9.5.9 Relationship: Pearson's Correlation
9.5.10 Relationship: The Chi-Square Test
9.5.11 Relationship: Linear Regression
9.5.12 Relationship: Logistic Regression
9.6 Wrap Up
9.7 Exercises
References
Chapter 10 Machine Learning with Python
10.1 Introduction
10.2 Types of Machine Learning Algorithms
10.3 Supervised Learning Algorithms: Linear Regression
10.4 Supervised Learning Algorithms: Logistic Regression
10.5 Supervised Learning Algorithms: Classification and Regression Tree (CART)
10.6 Supervised Learning Algorithms: Naïve Bayes Classifier
10.7 Unsupervised Learning Algorithms: K-means Clustering
10.8 Unsupervised Learning Algorithms: Apriori
10.9 Other Learning Algorithms
10.10 Wrap Up - Machine Learning Applications
10.11 Case Studies
10.12 Exercises
References
Chapter 11 Introduction to Neural Networks and Deep Learning
11.1 Introduction
11.2 Relevant Algebraic Math and Associated Python Methods for DL
11.2.1 The Dot Method
11.2.2 Matrix Operations with Python
11.2.3 Eigenvalues, Eigenvectors and Diagonals
11.2.4 Solving Sets of Equations with Python
11.2.5 Generating Random Numbers for Matrices with Python
11.2.6 Plotting with Matplotlib
11.2.7 Linear and Logistic Regression
11.3 Introduction to Neural Networks
11.3.1 Modelling a Simple ANN with a Perceptron
11.3.2 Sigmoid and Rectifier Linear Unit (ReLU) Methods
11.3.3 A Real-Life Example: Preparing the Dataset
11.3.4 Creating and Compiling the Model
11.3.5 Stochastic Gradient Descent and the Loss Method and Parameters
11.3.6 Fitting and Evaluating the Models, Plotting the Observed Losses
11.3.7 Model Overfit and Underfit
11.4 Wrap Up
11.5 Case Study
References
Chapter 12 Virtual Reality Application Development with Python
12.1 Introduction
12.2 3D Video Game Engines and VR Development Platforms
12.3 Motion Trackers and Head Mounted Displays VS Keyboards, Mice and Display Screens
12.4 The Vizard Environment and Creating the Graphics Window
12.5 Creating the 3D World
12.6 Collisions and Gravity
12.7 Creating Additional 3D Objects
12.8 3D (Cartesian) Coordinates and Basic Object Positioning
12.9 Euler Angles and Object Orientation
12.10 Absolute vs Relative Positioning
12.11 Creating and Positioning Multiple Objects through Lists
12.12 Using Prefabricated Animations
12.13 Basic Movement
12.14 Basic Interaction
12.15 Integrating VR Hardware and Exporting a Standalone.exe File
12.16 Conclusion
12.17 Case Study
References
Appendix: Case Studies Solutions
Index