Table of Contents
- Foreword — 13
- Chapter 1 - Language Overview: Python, Java, and C# — 15
- 1.1 Introduction — 15
- 1.1.1 Python — 15
- 1.1.2 Java — 15
- 1.1.3 C# — 15
- 1.2 Comparative Analysis — 16
- 1.2.1 Syntax and Readability — 16
- 1.2.2 Libraries and Ecosystem — 16
- 1.2.3 Performance and Efficiency — 16
- 1.2.4 Practical Applications — 17
- 1.1 Introduction — 15
- Chapter 2 - Program Structure and Input/Output Mechanisms in Python, Java and C# — 19
- 2.1 Introduction — 19
- 2.2 Understanding Basic Program Structure Across Java, C#, and Python — 20
- 2.2.1 Java Basic Program — 20
- 2.2.2 Breakdown of the program — 20
- 2.2.3 C# Basic Program — 21
- 2.2.4 Breakdown of the program — 21
- 2.2.5 Python Basic Program — 22
- 2.2.6 Breakdown of the program — 23
- 2.2.7 Comparative Synoptic Table of Java, C#, and Python Basic Programs — 24
- 2.3 Java, C# and Python Standard Input/Output — 24
- 2.3.1 Java Standard Input/Output — 24
- 2.3.2 C# Standard Input/Output — 28
- 2.3.3 Python Standard Input/Output — 31
- 2.4 Java, C# and Python Input/Output via Dialog Boxes — 35
- 2.4.1 Parsing Numeric Strings in Java, C#, and Python — 35
- 2.4.2 Formatting the Output Using Dialog Boxes — 39
- 2.4.3 Formatting the Output Using the String Method Format — 41
- 2.5 Lab Exercise 1 — 43
- 2.6 Solution Lab Exercise 1 — 45
- 2.7 Lab Exercise 2 — 49
- 2.8 Solution Lab Exercise 2 — 51
- Chapter 3 - Lexical Structure and Tokenization in Python, Java and C# — 57
- 3.1 Introduction — 57
- 3.2 Tokens in Programming Languages — 58
- 3.2.1 Tokens in Java — 58
- 3.2.2 Tokens in C# — 59
- 3.2.3 Tokens in Python — 59
- 3.2.4 Compilation and Interpretation Process — 59
- 3.3 Comments — 60
- 3.3.1 Comments in Java Programming — 60
- 3.3.2 Comments in C# Programming — 61
- 3.3.3 Comments in Python Programming — 62
- 3.3.4 Comparison of Comments in Java, C#, and Python — 63
- 3.4 Keywords — 64
- 3.4.1 Characteristics of Keywords — 64
- 3.4.2 Examples of Keywords in the three Programming Languages — 64
- 3.5 Identifiers — 65
- 3.5.1 Characteristics of Identifiers — 65
- 3.5.2 Identifiers in Java — 66
- 3.5.3 Identifiers in C# — 66
- 3.5.4 Identifiers in Python — 67
- 3.6 Symbols or Syntax Tokens — 67
- 3.6.1 Separators — 68
- 3.6.2 Punctuators — 68
- 3.6.3 Delimiters — 68
- 3.6.4 Symbols in Java and C# — 68
- 3.6.5 Symbols in Python — 71
- 3.6.6 Comparison of Symbols in Python, Java and C# — 73
- 3.7 Literals — 73
- 3.7.1 String Literals — 73
- 3.7.2 Character Literals — 75
- 3.7.3 Character Literals in Python — 75
- 3.7.4 Character Literals in Java and C# — 75
- 3.7.5 Numeric Literals — 76
- 3.7.6 Boolean Literals — 78
- 3.7.7 Collection Literals — 79
- 3.8 Lab Exercise 3 — 83
- 3.9 Solution Lab Exercise 3 — 85
- Chapter 4 - Operators and Expression Evaluation in Python, Java, and C# — 97
- 4.1 Introduction — 97
- 4.2 Operators — 98
- 4.3 Assignment Operators — 99
- 4.3.1 Identical Assignment Operators Across Python, Java, and C# — 99
- 4.3.2 Python Specific Assignment Operators — 99
- 4.3.3 Java and C# Specific Assignment Operators — 99
- 4.4 Arithmetic Operators — 100
- 4.4.1 Common Arithmetic Operators Across Python, Java, and C# — 100
- 4.4.2 Python-Specific Arithmetic Operators — 100
- 4.4.3 Examples of Arithmetic Operators in Python, Java, and C# — 101
- 4.5 Unary Operators — 102
- 4.5.1 Common Arithmetic Operators Across Python, Java, and C# — 102
- 4.5.2 Python-Specific Unary Operators — 104
- 4.5.3 Java and C# Specific Unary Operators — 105
- 4.6 Relational Operators — 108
- 4.6.1 Common Relational Operators Across Python, Java, and C# — 108
- 4.6.2 Python Specific Relational Operator — 108
- 4.7 Logical Operators — 110
- 4.7.1 Common Logical Operators Across Python, Java, and C# — 110
- 4.7.2 Digital Electronic Truth Tables — 110
- 4.7.3 Short-Circuit Evaluation — 112
- 4.8 Ternary Operators — 113
- 4.8.1 Ternary Operator in Java and C# — 114
- 4.8.2 Ternary Operator in Python — 114
- 4.9 Bitwise and Shift Operators — 115
- 4.9.1 Common Bitwise Operators Across Python, Java, and C# — 115
- 4.9.2 Bitwise Shift Operators — 116
- 4.10 Membership Operators — 117
- 4.10.1 Python Membership Operators — 117
- 4.10.2 Java Membership Equivalent — 118
- 4.10.3 C# Membership Equivalent — 118
- 4.11 Operator Precedence — 119
- 4.11.1 Unary Operators (!, +, -) — 119
- 4.11.2 Multiplication, Division, Modulus (*, /, %) — 120
- 4.11.3 Addition and Subtraction (+, -) — 120
- 4.11.4 Relational Operators (<, <=, >=, >) — 121
- 4.11.5 Equality Operators (==, !=) — 122
- 4.11.6 Logical AND (&&) — 122
- 4.11.7 Logical OR (||) — 123
- 4.11.8 Assignment (=) — 123
- 4.12 Lab Exercise 4 — 125
- 4.13 Solution Lab Exercise 4 — 128
- Chapter 5 - Data Representation and Memory Models in Python, Java, and C# — 143
- 5.1 Introduction — 143
- 5.2 Primitive Types — 144
- 5.2.1 Java Primitive Types — 144
- 5.2.2 C# Primitive Types — 145
- 5.2.3 Python Primitive Types — 145
- 5.2.4 Comparison of Primitive Types — 146
- 5.3 Type Conversion (Casting) — 147
- 5.3.1 Implicit Type Conversion (Automatic Conversion) — 147
- 5.3.2 Explicit Type Conversion (Casting) — 147
- 5.4 Objectives of Data Handling in Programming — 151
- 5.5 Named Constants and Variables — 151
- 5.5.1 Named Constants — 151
- 5.5.2 Variables — 151
- 5.6 Memory Allocation — 152
- 5.6.1 Concept — 152
- 5.6.2 Storing Data into Named Constant — 152
- 5.6.3 Storing Data in Variables — 153
- 5.7 Memory Allocation and Data Storage — 156
- 5.7.1 Memory Allocation and Data Storage in Java — 156
- 5.7.2 Memory Allocation and Data Storage in C# — 157
- 5.7.3 Memory Allocation and Data Storage in Python — 158
- 5.8 Memory Management — 159
- 5.8.1 Memory Management in Java and C# — 159
- 5.8.2 Memory Management in Python — 159
- 5.9 Comparing Floating-point Numbers for Equality — 160
- 5.9.1 Comparing Floating-point Numbers for Equality in Java — 160
- 5.9.2 Comparing Floating-point Numbers for Equality in C# — 160
- 5.9.3 Comparing Floating-point Numbers for Equality in Python — 161
- 5.10 Lab Exercise 5 — 162
- 5.11 Solution Lab Exercise 5 — 165
- Chapter 6 - Control Flow Semantics and Execution Structures in Python, Java, and C# — 177
- 6.1 Introduction — 177
- 6.2 Understanding Control Structures in Programming — 178
- 6.3 Types of Control Structures — 179
- 6.4 Selection Structures — 180
- 6.4.1 One-Way Selection — 180
- 6.4.2 Two-Way Selection — 182
- 6.4.3 Behavior of If Statements Without Curly Braces in Java and C# — 184
- 6.4.4 Nested if and if-elif-else in Python, Java, and C# — 186
- 6.4.5 Rule to Pair an else with an if in Java and C# — 191
- 6.4.6 Rule to Pair an else with an if in Python — 192
- 6.4.7 Match-Case (Python) and Switch-Case (Java and C#) — 193
- 6.5 Repetition Structures — 198
- 6.5.1 For Looping Structure — 198
- 6.5.2 While Looping Structure — 206
- 6.5.3 do … while Looping Structure — 217
- 6.5.4 Comparative Analysis of Repetition Structures — 220
- 6.6 Method Calls — 221
- 6.6.1 Method Calls in Java — 221
- 6.6.2 Method Calls in C# — 222
- 6.6.3 Method Calls in Python — 222
- 6.7 Lab Exercise 6 — 224
- 6.8 Solution Lab Exercise 6 — 227
- 6.9 Lab Exercise 7 — 233
- Chapter 7 - Arrays and Sequential Data Structures in Python, Java, and C# — 243
- 7.1 Introduction — 243
- 7.2 Array Definition — 244
- 7.3 Arrays and their Components — 245
- 7.4 Size of an Array — 246
- 7.5 Array Declaration — 246
- 7.5.1 Declaring an Array in Java — 246
- 7.5.2 Declaring an Array in C# — 247
- 7.5.3 Declaring an Array in Python — 247
- 7.6 Array memory allocation — 247
- 7.6.1 Array memory allocation in Java and C# — 247
- 7.6.2 Array memory allocation in Python — 248
- 7.6.3 Key Differences in Memory Allocation — 249
- 7.7 Array Initialization — 249
- 7.7.1 Initializing an Array in Java and C# — 249
- 7.7.2 Initializing an Array in Python — 252
- 7.8 Understanding Array Size in Java, C#, and Python — 253
- 7.8.1 Array Size in Java — 253
- 7.8.2 Array Size in C# — 254
- 7.8.3 Array Size in Python — 255
- 7.8.4 Comparing Array Size Handling Across Java, C#, and Python — 255
- 7.9 Accessing Array Elements — 256
- 7.9.1 General Concept of Array Indexing — 256
- 7.9.2 Accessing Array Elements in Java — 256
- 7.9.3 Accessing Array Elements in C# — 257
- 7.9.4 Accessing Array Elements in Python — 257
- 7.9.5 Array Operations in Java, C# and Python — 258
- 7.10 Lab Exercise 8 — 265
- 7.11 Solution Lab Exercise 8 — 268
- 7.12 Lab Exercise 9 — 271
- 7.13 Solution Lab Exercise 9 — 273
- 7.14 Lab Exercise 10 — 276
- 7.15 Solution Lab Exercise 10 — 280
- About the Author — 287
- The Side-by-Side Programming Series — 288
- Author’s Publishing Collections — 289