Introduction xv PART I: IT''S ALL FUN AND GAMES 1 Chapter 1 Getting Started 3 Understanding Computer Programming 4 What is a computer? 4 How do we talk to computers? 5 What is Python? 8 Setting Things Up 9 Installing Python 9 Installing and Configuring Visual Studio Code 10 Creating a Work Folder 13 Writing Your First Python Program 15 Selecting Your Work Folder 16 It''s Coding Time! 17 Summary 19 Chapter 2 Mad Libs 21 Understanding Functions 22 Using Variables 23 Creating a Variable 24 Using a Variable 24 Some Important Variable Rules 25 Variables, More Variables, and Even More Variables 26 Getting User Input 28 Playing Mad Libs 30 Write Your Story 30 Add Variables 30 Get User Input 32 Summary 33 Chapter 3 Roll the Dice 35 Using Libraries 36 The random Library 36 Generating Random Numbers 37 Choosing a Random Item 38 "3" Is Not 3 41 Commenting Your Code 43 One Die, Two Dice 45 Summary 49 Chapter 4 Calculate the Day 51 Working with Dates 52 The datetime Library 52 Using the datetime Class 55 Making Decisions 56 The if Statement 56 What else? 58 if Revisited 59 Testing for Other Options 61 Using in 62 Beating the Mathematician 63 Handling Numeric Inputs 63 Putting It All Together 64 An Alternate Solution 67 Summary 67 Chapter 5 Rock Paper Scissors 69 More Strings 70 Game Time 72 Handling User Input 72 The Game Code 74 One Last Tweak 76 Summary 77 Chapter 6 Secret Codes 79 Lists 80 Creating Lists 80 Accessing List Items 82 Changing List Items 83 Adding and Removing Items 84 Finding Items 85 Sorting 86 Loop-de-Loop 89 Looping Through Items 90 Looping Through Numbers 92 Nested Loops 93 Cracking the Code 95 Encrypting Characters 96 Modulus Math 97 Encryption Code 98 Decryption Code 102 Summary 104 Chapter 7 Guess the Number 105 Conditional Loops 106 Game Time 111 The Basic Game 111 Putting It All Together 116 Summary 120 Chapter 8 Becoming a Coder 121 How Coders Code 122 Have a Plan 122 Think Small 123 Game Components 124 Restricting User Input 125 Storing User Guesses 128 Displaying Lists 129 Masking Characters 131 Summary 136 Chapter 9 Hangman 137 Game Time 138 So How Does It Work? 141 Summary 148 Chapter 10 Keep Going 149 Birthday Countdown 150 Program Requirements 150 Program Flow 150 Some Tips 151 Tip Calculator 152 Program Requirements 152 Program Flow 153 Some Tips (Pun Intended) 153 Password Generator 154 Program Requirements 154 Program Flow 155 Some Tips 155 Summary 159 PART II: ON AN ADVENTURE 161 Chapter 11 Getting Func-ky 163 Functions Revisited 164 Creating a Function 165 Passing Arguments 167 Returning Values 171 Summary 175 Chapter 12 Exploring 177 Game Concept 178 Game Structure 179 Prompting for Options 181 Processing Options 182 Create a Work Folder 183 Game Time 184 Test It 189 Summary 191 <.
Captain Code : Unleash Your Coding Superpower with Python