John Wiley & Sons Job Ready Python Cover Get ready to take on Python with a practical and job-focused guide Job Ready Python offers readers .. Product #: 978-1-119-81738-3 Regular price: $35.42 $35.42 In Stock

Job Ready Python

Balti, Haythem / Weiss, Kimberly A.

Cover

1. Edition December 2021
688 Pages, Softcover
Wiley & Sons Ltd

ISBN: 978-1-119-81738-3
John Wiley & Sons

Buy now

Price: 37,90 €

Price incl. VAT, excl. Shipping

Further versions

epubmobipdf

Get ready to take on Python with a practical and job-focused guide

Job Ready Python offers readers a straightforward and elegant approach to learning Python that emphasizes hands-on and employable skills you can apply to real-world environments immediately.

Based on the renowned mthree Global Academy and Software Guild training program, this book will get you up to speed in the basics of Python, loops and data structures, object-oriented programming, and data processing. You'll also get:
* Thorough discussions of Extract, Transform, and Load (ETL) scripting in Python
* Explorations of databases, including MySQL, and MongoDB--all commonly used database platforms in the field
* Simple, step-by-step approaches to dealing with dates and times, CSV files, and JSON files

Ideal for Python newbies looking to make a transition to an exciting new career, Job Ready Python also belongs on the bookshelves of Python developers hoping to brush up on the fundamentals with an authoritative and practical new handbook.

About the Authors v

About the Technical Writer v

About the Technical Editor v

Acknowledgments vi

Introduction xvii

Part I: Getting Started with Python 1

Lesson 1: Setting Up a Python Programming Environment 3

Python Overview 4

Using Replit Online 4

Creating a Replit Account 5

Creating a Python Program in Replit 7

Running a Python Program in Replit 9

Other Replit Tasks 11

Renaming Your Code File 11

Saving Your Coding File Locally 12

Creating a New File for Your Python Project 12

Adding Files to Your Python Project 13

Returning to Replit 13

Getting More Help for Replit 14

Getting Started with Jupyter Notebook 14

Installing Anaconda Jupyter Notebook 15

Creating a New Jupyter Notebook File 16

Renaming a Jupyter Notebook Project File 18

Saving a Python File Locally 19

Opening an Existing Jupyter Notebook File 20

A Quick Look at Visual Studio Code 21

Obtaining Visual Studio Code 21

Adding the Python Extension to Visual Studio Code 22

Using Python from the Command Line 24

Summary 26

Exercises 26

Exercise 1: Say Hello 27

Exercise 2: What's It Do? 27

Exercise 3: Counting 27

Exercise 4: Fruity Code 28

Lesson 2: Understanding Programming Basics 29

The Future of Computer Programming 30

What Is Programming? 30

What Is a Program? 30

Computational Thinking 31

Programming Languages 32

Common Components 33

Statements 33

Syntax 33

Reserved Words 34

Operators 35

Hello, World! 36

Data Types and Variables 37

Data Types 37

Text 38

Numbers 38

True/False 39

Date/Time 39

Data Collections 39

Variables 40

Reserving Memory 42

Variables and Data Types 43

Constants 44

Example 1: Area of a Circle 44

Example 2: Tax Rate 45

Example 3: Output Messages 45

Summary 46

Exercises 46

Exercise 1: Daily Tasks 47

Exercise 2: Python Programming 47

Lesson 3: Exploring Basic Python Syntax 49

Using with Single-Line Commands 51

Using Semicolons 52

Continuing with Backslash 54

Working with Case Structure 55

Adding Comments 56

Using the Input Function 57

Storing Input 59

Understanding Variable Types 61

Displaying Variable Values 62

Naming Variables 64

Summary 65

Exercises 65

Exercise 1: Displaying Text 66

Exercise 2: Follow the Comments 66

Exercise 3: Fixing the Code 66

Exercise 4: Broken Variables 67

Exercise 5: Broken Names 67

Exercise 6: Where Are You? 67

Lesson 4: Working with Basic Python Data Types 69

Review of Data Types 70

Number Data Types 70

Identifying Data Types 72

Mathematical Operations 74

PEMDAS 77

Common Math Functions 81

Math Library Functions 83

Using Numbers with User Input 86

Boolean Types and Boolean Operations 89

Convert to Boolean 90

Logic Operations 92

Comparative Operators 95

Summary 96

Exercises 97

Exercise 1: Prompting the User 97

Exercise 2: Manipulated Math 97

Exercise 3: Integers Only 98

Exercise 4: Current Value 98

Exercise 5: Simple Interest 98

Exercise 6: True or False 99

Exercise 7: Playing with Numbers 99

Exercise 8: Do the Math 99

Exercise 9: Street Addresses 100

Lesson 5: Using Python Control Statements 101

Control Structures Review 101

Understanding Sequence Control Structure 102

Understanding Selection Statements 103

Understanding Conditional Statements 106

If-Else Statements 108

Working with Nested Conditions 109

Embedding Conditions 112

Summary 114

Exercises 114

Exercise 1: Are You Rich? 115

Exercise 2: Cats or Dogs 115

Exercise 3: True or False Quiz 115

Exercise 4: For Every Season... 115

Exercise 5: Company Picnic 116

Lesson 6: Pulling It All Together: Income Tax Calculator 117

Getting Started 118

Step 1: Gather Requirements 118

Values in Use 119

User Interface 119

Other Standards 120

Step 2: Design the Program 120

Step 3: Create the Inputs 120

Step 4: Calculate the Taxable Income 122

Step 5: Calculate the Tax Rate 124

Add a Conditional Statement 125

Create Nested Conditionals 127

Step 6: Update the Application 133

What About Negative Taxable Incomes? 134

Does Code Compare to Standards? 136

Step 7: Address the UI 136

On Your Own 139

Summary 139

Part II: Loops and Data Structures 141

Lesson 7: Controlling Program Flow with Loops 143

Iterations Overview 144

The Anatomy of a Loop 144

The for Loop 145

The while Loop 146

Unexecutable while Loop 148

for vs. while Loops 149

Strings and String Operations 151

Determining the Length of a String 152

Splitting a String 153

Storing Characters 154

Comparison Operators in Strings 155

Concatenating Strings 158

Slicing Strings 159

Searching Strings 163

Iterating through Strings 164

Summary 167

Exercises 167

Exercise 1: Separating Your Fruits 168

Exercise 2: Keeping It Short 168

Exercise 3: Fruit Finder 168

Exercise 4: It's Divisible 169

Exercise 5: Identify the Numbers 169

Exercise 6: And the Total Is... 169

Exercise 7: Multiplication Tables 169

Exercise 8: Sum of Prime Numbers 169

Exercise 9: One Letter at a Time 170

Exercise 10: Length without len() 170

Exercise 11: Count the Numbers 170

Exercise 12: Fizz Buzz 170

Lesson 8: Understanding Basic Data Structures: Lists 173

Data Structure Overview--Part 1 174

Creating Lists 175

Determining List Length 179

Working with List Indexes 179

Negative Indexing in Lists 182

Slicing Lists 184

Using the Slice Object 187

Adding Items to a List 189

Inserting List Items 190

Removing List Items 192

Deleting versus Removing Items 194

Popping Instead of Removing 195

Concatenating Lists 196

List Comprehension 197

Sorting Lists 199

Copying Lists 200

Summary 202

Exercises 202

Exercise 1: All About You 203

Exercise 2: Shopping List 203

Exercise 3: List Deletion 203

Exercise 4: List Modification 203

Exercise 5: A Complete

List Program 203

Lesson 9: Understanding Basic Data Structures: Tuples 205

Tuples and Tuple Operations 206

Syntax of Tuples vs. Syntax of Lists 206

Tuple Length 208

Tuple Index Values 209

Negative Indexing in Tuples 210

Slicing Tuples 212

Immutability 213

Concatenating Tuples 216

Searching Tuples 217

Summary 218

Exercises 219

Exercise 1: Creating Tuples 219

Exercise 2: Modifying Tuples 219

Exercise 3: Where's Waldo? 220

Exercise 4: A Complete Tuple Program 220

Lesson 10: Diving Deeper into Data Structures: Dictionaries 223

Data Structure Overview--Part 2 224

Getting Started with Dictionaries 224

Generating a Dictionary 227

Retrieving Items from a Dictionary 230

Using the keys() Method 233

Using the items() Method 234

Reviewing the keys(), values(), and items() Methods 236

Using the get() Method 239

Using the pop() Method 241

Working with the in Operator 245

Updating a Dictionary 246

Duplicating a Dictionary 249

Clearing a Dictionary 254

Summary 255

Exercises 255

Exercise 1: Working with Text 256

Exercise 2: Separating the High from the Low 256

Exercise 3: High and Low All in One 257

Exercise 4: Self-Assessment 257

Lesson 11: Diving Deeper into Data Structures: Sets 259

Sets 260

Retrieving Items from a Set 261

Adding Items to a Set 262

Creating an Empty Set 262

Understanding Set Uniqueness 263

Searching Items in a Set 265

Calculating the Length of a Set 267

Deleting Items from a Set 268

Clearing a Set 270

Popping Items in a Set 272

Deleting a Set 273

Determining the Difference

Between Sets 274

Intersecting Sets 277

Combining Sets 278

Summary 279

Exercises 279

Exercise 1: Line by Line 280

Exercise 2: Adding New Names 280

Exercise 3: Popping Accounts 280

Exercise 4: Everywhere That

Mary Went... 280

Exercise 5: Self-Assessment 281

Lesson 12: Pulling It All Together: Prompting for an Address 283

Step 1: Getting Started 284

Step 2: Accept User Input 285

Step 3: Display the Input Value 286

Step 4: Modify the Output 287

Step 5: Split a Text Value 288

Step 6: Display Only the House Number 290

Step 7: Display the Street Name 291

Step 8: Add the Period 292

Summary 293

Lesson 13: Organizing with Functions 295

Functions Overview 295

Defining Functions in Python 296

Function Syntax 300

Default Input Values 301

Parameter Syntax 303

Arbitrary Arguments 304

Keyword Arguments 306

Arbitrary Keyword Arguments 306

Summary 308

Exercises 309

Exercise 1: Lower Numbers 309

Exercise 2: This Will Be 309

Exercise 3: Finding the Largest 310

Exercise 4: Simple Calculator 310

Exercise 5: Which Is Greater? 310

Part III: Object-Oriented Programming in Python 311

Lesson 14: Incorporating Object-Oriented Programming 313

Object-Oriented Programming Overview 314

Defining Classes 314

Attributes 315

Methods 316

Creating Objects 316

Working with Methods 319

Class Attributes 324

Working with Static Methods 326

Working with Class Methods 328

Summary 330

Exercises 330

Exercise 1: Create Your Own Class 331

Exercise 2: Classy Vehicles 331

Exercise 3: Streamlined Banking 331

Exercise 4: Using a Calculator in

Class 331

Lesson 15: Including Inheritance 333

Understanding Inheritance 334

Creating a Parent Class 335

Creating a Child Class 335

Inheriting at Multiple Levels 338

Overriding Methods 340

Summary 343

Exercises 344

Exercise 1: Basic Inheritance 344

Exercise 2: Adding Attributes 344

Exercise 3: Creating More Children 345

Exercise 4: Dogs and Cats 345

Exercise 5: Hourly Employees 345

Exercise 6: File System 347

Lesson 16: Pulling It All Together: Building a Burger Shop 349

Requirements for Our Application 350

Plan the Code 350

Create the Classes 351

Create the Food Item Class 352

Create a Burger Class 353

Create a Drink Class 354

Create a Side Class 354

Create a Combo 355

Create the Order Class 356

Create the Main File 357

Create order once 358

Order a Burger 359

Add a Drink 360

Add Sides 362

Order a Combo 363

Display the Output 364

Tie the Code Files Together 364

Summary 368

Part IV: Data Processing with Python 369

Lesson 17: Working with Dates and Times 371

Getting Started with Dates and Times 372

Creating a Variable for a Date 372

Creating a Variable for Time 375

Creating a Variable for Both Date and Time 375

Getting the Current Date and Time 376

Splitting a Date String 377

Using datetime Attributes 379

Creating Custom datetime Objects 380

Compare datetime Values 381

Working with UTC Format 383

Applying Timestamps 384

Arithmetic and Dates 387

Calculating the Difference in Days 388

Using Date without Time 390

Using Time without Date 392

Summary 394

Exercises 394

Exercise 1: Displaying Dates 394

Exercise 2: Leap Years 395

Exercise 3: The Past 395

Exercise 4: Unix Dates 395

Exercise 5: Yesterday, Today, and Tomorrow 395

Exercise 6: Setting Future Days 395

Exercise 7: Five Seconds in the Future 395

Exercise 8: Date Calculators 396

Calculator 1: Time Duration 396

Calculator 2: Add or Subtract

Time from a Date 397

Calculator 3: Age Calculator 397

Lesson 18: Processing Text Files 399

File Processing Overview 401

Introduction to File Input/Output 402

The input() Function 402

The open() Function 402

The read() Method 403

The write() Method 403

The close() Method 403

The print() Function 403

Processing Text Files 404

Opening a File 404

Reading Text from a File 406

Use the read() Method to Limit the Content 406

Reading Lines 408

Iterating through a File 410

Add Content to a File 412

Overwriting the Contents of a File 415

Creating a New File 417

Using the os Module 418

Deleting a File 419

Summary 421

Exercises 421

Exercise 1: Reading Lines 422

Exercise 2: Combination of the Two 422

Exercise 3: Combination of Them All 422

Exercise 4: Listing Lines 422

Exercise 5: Longest Word 422

Exercise 6: Listing Text 423

Exercise 7: Text in Reverse 423

Lesson 19: Processing CSV Files 425

Reading CSV Files 426

Using the DictReader Class 430

Creating a Dataset List 432

Using writerow() 434

Appending Data 436

Writing Rows as Lists 439

Writing Rows from Dictionaries 440

Summary 444

Exercises 444

Exercise 1: Reading Lines 444

Exercise 2: Company Stocks 444

Exercise 3: Rearranging Files 445

Exercise 4: Pop Music Evolution 445

Exercise 5: All About Cars 446

Lesson 20: Processing JSON Files 447

Processing JSON Files 448

Creating a JSON File with dump() 448

Converting to JSON with dumps() 449

Formatting JSON Data 450

Using json.loads() 452

Iterating through JSON Data 454

Reading and Writing JSON Data 457

Summary 460

Exercises 461

Exercise 1: Company Bank Account 461

Exercise 2: Formatted Account Information 461

Exercise 3: Nobel Prizes 461

Exercise 4: New York Restaurants 462

Exercise 5: Movies 463

Part V: Data Analysis and Exception Handling 465

Lesson 21: Using Lambdas 467

Creating a Lambda Function 468

Working with Multiple Inputs 469

Placing Lambda Functions inside a Function 471

Using the map() Function 472

Combining Map and Lambda Functions 475

Using the filter() Function 477

Combining a Filter and a Lambda 479

Using the reduce() Function 480

Specify an Initial Value 482

Using reduce() with Comparison Operations 484

Summary 486

Exercises 486

Exercise 1: Computing the Square Root 487

Exercise 2: Converting a Text File to Uppercase 487

Exercise 3: Determining Prime 487

Exercise 4: Identifying Absolute Value 487

Exercise 5: Highest Number 487

Exercise 6: Lowest Number 487

Exercise 7: Last Key 487

Exercise 8: Highest Value 488

Exercise 9: Sum of Even 488

Exercise 10: Sum of Positive Numbers 488

Exercise 11: Highest Stock Market Volume 488

Exercise 12: Bad Stock Market Day 488

Exercise 13: Highest Opening Price 488

Exercise 14: Highest Price at Closing 489

Exercise 15: Self-Assessment 489

Lesson 22: Handling Exceptions 491

Built-In Exceptions 492

Working with try and except 493

Working with Multiple Excepts 495

Combining Exception Types 498

Using Multiple Operations in a try 500

Using the raise Keyword 501

Exploring the General Exception Classes 502

Adding finally 505

Summary 506

Exercises 506

Exercise 1: Typing Numbers 507

Exercise 2: Current Value 507

Exercise 3: Reading Lines 508

Exercise 4: Concatenating Files 508

Exercise 5: Creating a List from a File 508

Exercise 6: Self-Assessment 508

Lesson 23: Pulling It All Together: Word Analysis in Python 511

Examine the Data 512

Read the Data 514

Tokenize the Dataset 517

Tokenize an Input String 518

Tokenize an Input Review 521

Tokenize the Entire Dataset 522

Using the Tokenize Functions 523

Count the Words in Each Review 524

Word Count for an Input List of Words 524

Word Count an Input Review 525

Word Count for the Dataset 526

Summary 528

Lesson 24: Extracting, Transforming, and Loading with ETL Scripting 531

ETL Scripting in Python 532

Design and Implement Custom ETL Scripts 532

The extract Class 534

Adding the extract.fromCSV Method 534

Creating the extract.fromJSON Method 536

Creating the extract.fromMySQL Method 538

Creating the extract.fromMongoDB Method 542

Verify the extract.py Module 544

Using Our Script as an External Module 545

The transform Class 546

Defining the transform Class 546

Creating the head and tail Methods 547

Renaming a Column 551

Removing a Column from the Data Source 552

Renaming Multiple Columns 556

Removing Multiple Columns 558

Transforming the Data 563

The load Class 569

Creating the load.toCSV Method 570

Creating the load.toJSON Method 572

Creating the load.toMYSQL

Method 574

Creating the Load.toMONGODB Method 578

Summary 582

Exercises 582

Exercise 1: Transforming CSV to CSV 583

Exercise 2: Transforming CSV to JSON 583

Exercise 3: Transforming JSON to CSV 583

Exercise 4: Transforming JSON to JSON 583

Exercise 5: Removing an Attribute 583

Exercise 6: Renaming an Attribute 583

Exercise 7: Confirming an Attribute 584

Lesson 25: Improving ETL Scripting 585

Converting to Static Methods for the extract Class 586

Converting to Static Methods for the transform Class 588

Converting to Static Methods for the load Class 592

Adding Exception Handling in the extract Class 594

Creating a Custom Extractor for the extract Class 601

Summary 607

Exercises 608

Exercise 1: Revisiting Lessons Learned 608

Exercise 2: Day of Week 608

Exercise 3: Date Validity 609

Exercise 4: Listing Duplicates 609

Exercise 5: Removing Duplicates 609

Exercise 6: Transforming Names 609

Part VI: Appendices 611

Appendix A: Flowcharts 613

Flowchart Basics 613

Sequences 613

Branches 614

Loops 615

Common Flowcharting Shapes 615

Flowcharting Example 616

Additional Flowchart Elements 618

Appendix B: Creating Pseudocode 621

What Is Pseudocode? 621

Appendix C: Installing MySQL 623

MySQL Installation 623

Download and Install MySQL 623

Configure MySQL 624

Configure MySQL Router Options 626

Configure Samples and Examples 627

Verify the Installation 628

The MySQL Notifier 630

Appendix D: Installing Vinyl DB 631

Database Structure 631

Create the Database 632

Appendix E: Installing MongoDB 637

Installing MongoDB Community Server 637

Running MongoDB 642

Appendix F: Importing to MongoDB 643

Index 645
HAYTHEM BALTI, PhD, is the associate dean at Wiley's mthree academy. He has created courses used by thousands of Software Guild and mthree alumni to learn Go, Java, Python, and other development and data science skills.

KIMBERLY A. WEISS is a veteran course developer, specializing in Computer Science courses since 2002. She was an assistant professor in Computer Science for over ten years before deciding to focus exclusively on course design. She has worked with multiple universities as well as corporate training settings to develop interactive instructional content appropriate for the target learners and course goals.

H. Balti, mthree academy