Contents

Introduction

PART I: It’s All Fun and Games

CHAPTER 1 Getting Started

Understanding Computer Programming

What is a computer?

How do we talk to computers?

What is Python?

Setting Things Up

Installing Python

Installing and Configuring Visual Studio Code

Creating a Work Folder

Writing Your First Python Program

Selecting Your Work Folder

It’s Coding Time!

Summary

CHAPTER 2 Mad Libs

Understanding Functions

Using Variables

Creating a Variable

Using a Variable

Some Important Variable Rules

Variables, More Variables, and Even More Variables

Getting User Input

Playing Mad Libs

Write Your Story

Add Variables

Get User Input

Summary

CHAPTER 3 Roll the Dice

Using Libraries

The random Library

Generating Random Numbers

Choosing a Random Item

“3” Is Not 3

Commenting Your Code

One Die, Two Dice

Summary

CHAPTER 4 Calculate the Day

Working with Dates

The datetime Library

Using the datetime Class

Making Decisions

The if Statement

What else?

if Revisited

Testing for Other Options

Using in

Beating the Mathematician

Handling Numeric Inputs

Putting It All Together

An Alternate Solution

Summary

CHAPTER 5 Rock Paper Scissors

More Strings

Game Time

Handling User Input

The Game Code

One Last Tweak

Summary

CHAPTER 6 Secret Codes

Lists

Creating Lists

Accessing List Items

Changing List Items

Adding and Removing Items

Finding Items

Sorting

Loop-de-Loop

Looping Through Items

Looping Through Numbers

Nested Loops

Cracking the Code

Encrypting Characters

Modulus Math

Encryption Code

Decryption Code

Summary

CHAPTER 7 Guess the Number

Conditional Loops

Game Time

The Basic Game

Putting It All Together

Summary

CHAPTER 8 Becoming a Coder

How Coders Code

Have a Plan

Think Small

Game Components

Restricting User Input

Storing User Guesses

Displaying Lists

Masking Characters

Summary

CHAPTER 9 Hangman

Game Time

So How Does It Work?

Summary

CHAPTER 10 Keep Going

Birthday Countdown

Program Requirements

Program Flow

Some Tips

Tip Calculator

Program Requirements

Program Flow

Some Tips (Pun Intended)

Password Generator

Program Requirements

Program Flow

Some Tips

Summary

Part II: On an Adventure

CHAPTER 11 Getting Func-ky

Functions Revisited

Creating a Function

Passing Arguments

Returning Values

Summary

CHAPTER 12 Exploring

Game Concept

Game Structure

Prompting for Options

Processing Options

Create a Work Folder

Game Time

Test It

Summary

CHAPTER 13 Cleanup Time

Optimizing Your Code

String Externalization

Creating the Strings File

Using Externalized Strings

Summary

CHAPTER 14 Reduce, Reuse, Recycle, Refactor

Understanding Refactoring

Identifying Refactoring Opportunities

Creating a User Choice Component

Designing a Reusable Component

Creating the User Options Function

Updating Your Code

Summary

CHAPTER 15 Carrying (and Using) Stuff

Planning the Inventory System

Creating a Dictionary

Working with Dictionaries

Lists of Dictionaries

The Inventory System

Creating an Inventory

Plugging In the Inventory System

Using the Inventory System

Displaying the Inventory

Summary

CHAPTER 16 Keeping It Classy

The Player System

Creating a Player Class

Creating the Class

Defining Properties

Creating Methods

Initializing the Class

Using Our New Class

Summary

CHAPTER 17 Color Your World

Installing Third-Party Libraries

Using Colorama

Importing and Initializing the Library

Coloring Your Output

Summary

CHAPTER 18 Keep Going

Health and Lives

Shopping for Items

Random Events

Battling Enemies

Saving and Restoring

Summary

PART III: Racing Around

CHAPTER 19 Crazy Driver

Introducing Pygame

Prepping the Game

Game Concept

Installing Pygame

Creating Work Folders

Obtaining Images

Getting Started

Initializing Pygame

Displaying Stuff

The Game Loop

Summary

CHAPTER 20 Image-ine the Possibilities

Files and Folders

Setting the Background

Placing the Cars

Summary

CHAPTER 21 We Like to Move It

Moving the Enemy

Moving the Player

Summary

CHAPTER 22 Crash, Bang, Boom

You Crashed, Game Over

Tracking Score

Increasing Difficulty

Summary

CHAPTER 23 Finishing Touches

Game Over Revisited

Pause

Varying Enemies

Ice Cubes

Summary

CHAPTER 24 Keep Going

Splash Screen

Scores and High Scores

Oil Slick

Multiple Enemies

And Then…

Summary

What Next?

There’s a Lot More to Python

Web Development

Mobile App Development

Game Development

And Then…

Index

CHAPTER 25 Tinkering, Testing, and Debugging Revisited

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset