PYTHON PROGRAMMIN A to Z: A Comprehensive Guide to Programming Excellence

Python A to Z is your trusted companion in the realm of one of the world's most versatile programming languages. Em

123 90 18MB

English Pages 399 Year 2024

Report DMCA / Copyright

DOWNLOAD EPUB FILE

Table of contents :
Why Should You Learn to Write Programs? 9

1.1​Creativity and motivation ​14

1.2​Computer hardware architecture ​16

1.3​Understanding programming ​21

1.4​Words and sentences ​23

1.5​Conversing with Python ​30

1.6​Terminology: Interpreter and compiler 33

1.7​Writing a program ​40

1.8​What is a program? ​42

1.9​The building blocks of programs ​46

1.10​What could possibly go wrong? 49

1.11​Debugging ​77

1.12​The learning journey ​81

1.13​Glossary ​84

1.14​Exercises ​88

Variables, Expressions, and Statements 91

2.1​Values and types ​91

2.2​Variables ​95

2.3​Variable names and keywords ​97

2.4​Statements ​99

2.5​Operators and operands ​101

2.6​Expressions ​103

2.7​Order of operations ​105

2.8​Modulus operator ​107

2.9​String operations ​108

2.10​Asking the user for input ​109

2.11​Comments ​113

2.12​Choosing mnemonic variable names 115

2.13​Debugging ​120

2.14​Glossary ​153

2.15​Exercises ​155

Conditional Execution ​129

3.1​Boolean expressions ​129

3.2​Logical operators ​131

3.3​Conditional execution ​132

3.4​Alternative execution ​136

3.5​Chained conditionals ​138

3.6​Nested conditionals ​140

3.7​Catching exceptions using try and except 143

3.8​Short-circuit evaluation of logical expressions 147

3.9​Debugging ​152

3.10​Glossary ​153

3.11​Exercises ​156

Functions ​159

4.1​Function calls ​159

4.2​Built-in functions ​161

4.3​Type conversion functions ​163

4.4​Math functions ​165

4.5​Random numbers ​169

4.6​Adding new functions ​173

4.7​Definitions and uses ​177

4.8​Flow of execution ​180

4.9​Parameters and arguments ​182

4.10​Fruitful functions and void functions 185

4.11​Why functions? ​189

4.12​Debugging ​191

4.13​Glossary ​193

4.14​Exercises ​196

Iteration ​201

5.1​Updating variables ​201

5.2​The while statement ​203

5.3​Infinite loops ​206

5.4​Finishing iterations with continue ​210

5.5​Definite loops using for ​212

5.6​Loop patterns ​215

5.6.1​Counting and summing loops 215

5.6.2​Maximum and minimum loops 219

5.7​Debugging ​223

5.8​Glossary ​225

5.9​Exercises ​226

Strings ​228

6.1​A string is a sequence ​228

6.2​Getting the length of a string using Len 230

6.3​Traversal through a string with a loop 231

6.4​String slices ​234

6.5​Strings are immutable ​236

6.6​Looping and counting ​237

6.7​The in operator ​239

6.8​String comparison ​240

6.9​String methods ​241

6.10​Parsing strings ​248

6.11​Formatted String Literals ​250

6.12​Debugging ​251

6.13​Glossary ​256

6.14​Exercises ​258

Files ​259

7.1​Persistence ​259

7.2​Opening files ​261

7.3​Text files and lines ​264

7.4​Reading files ​267

7.5​Searching through a file ​272

7.6​Letting the user choose the file name 279

7.7​Using try, except, and open ​282

7.8​Writing files ​286

7.9​Debugging ​289

7.10​Glossary ​291

7.11​Exercises ​292

Lists ​295

8.1​A list is a sequence ​295

8.2​Lists are mutable ​297

8.3​Traversing a list ​299

8.4​List operations ​301

8.5​List slices ​302

8.6​List methods ​304

8.7​Deleting elements ​306

8.8​Lists and functions ​308

8.9​Lists and strings ​312

8.10​Parsing lines ​315

8.11​Objects and values ​317

8.12​Aliasing ​320

8.13​List arguments ​322

8.14​Debugging ​325

8.15​Glossary ​337

8.16​Exercises ​338

Dictionaries ​348

9.1​Dictionary as a set of counters ​348

9.2​Dictionaries and files ​353

9.3​Looping and dictionaries ​357

9.4​Advanced text parsing ​360

9.5​Debugging ​364

9.6​Glossary ​367

9.7​Exercises ​368

Tuples ​371

10.1​Tuples are immutable ​371

10.2​Comparing tuples ​375

10.3​Tuple assignment ​378

10.4​Dictionaries and tuples ​383

10.5​Multiple assignments with dictionaries 384

10.6​The most common words ​387

10.7​Using tuples as keys in dictionaries 390

10.8​Sequences: strings, lists, and tuples - Oh My! 391

10.9​List comprehension ​394

10.10 Debugging ​395

10.11​Glossary ​396

10.12​Exercises ​398

PYTHON PROGRAMMIN A to Z: A Comprehensive Guide to Programming Excellence

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
Recommend Papers