Summary
Hello World! Computer Programming for Kids and Other Beginners, Third Edition introduces the world of computer programming in a clear and fun style using Python, a programming language designed to be easy to learn.
About the Technology
Learn to talk to your computer in its own language! Whether you want to create a game, start a business, or solve an important problem, the first step is learning to write your own programs.
About the Book
Hello World! Computer Programming for Kids and Other Beginners, Third Edition introduces the world of computer programming in a clear and fun style. Using Python, a programming language designed to be easy to learn, each engaging lesson teaches skills that apply to any kind of programming. It brings to life the basic concepts of computing--looping, decisions, input and output, graphics, and more.
Written by father-and-son team Warren and Carter Sande, this international bestseller is kid-tested and reviewed by professional educators. Now in its third edition, Hello World! has been fully updated to Python 3 and includes a new chapter about how the internet works.
What's inside
• Colorful pictures, clever cartoons, and fun examples
• Practice questions and exercises
• Updated to Python 3
About the Reader
You don't need to know anything about programming to use the book. If you can open an app and save a file, you're ready to go!
Author(s): Warren Sande, Carter Sande
Edition: 3
Publisher: Manning Publications
Year: 2019
Language: English
Commentary: Vector PDF
Pages: 496
City: Shelter Island, NY
Tags: Programming; GUI; Python; Object-Oriented Programming; Network Programming; Game Development; Children; Entry Level
Hello World!
Contents
Preface
What is programming?
Python—a language for us and the computer
Why learn programming?
Why Python?
Acknowledgments
Acknowledgments for the First Edition
Acknowledgments for the Second Edition
Acknowledgments for the Third Edition
About this book
What you need
What you don’t need
Using this book
Follow along with the examples
Installing Python
Type in the programs
Do the quiz questions
Carter says
What’s new in the Third Edition
Note to parents and teachers
Chapter 1 Getting Started
Installing Python
Starting Python with IDLE
Instructions, please
If it doesn’t work
Interacting with Python
Time to program
Running your first program
If something goes wrong
Syntax errors
Runtime errors
Our second program
What did you learn?
Test your knowledge
Try it out
Chapter 2 Remember This: Memory and Variables
Input, processing, output
Names
What’s in a name?
Numbers and strings
Long strings
How “variable” are they?
The new me
What did you learn?
Test your knowledge
Try it out
Chapter 3 Basic Math
The four basic operations
Operators
Order of operations
Integer division: Quotient and remainder
Exponentiation: Raising to a power
Increment and decrement
Really big and really small
E-notation
Exponents vs. E-notation
What did you learn?
Test your knowledge
Try it out
Chapter 4 Types of Data
Changing types
Changing an int to a float
Changing a float to an int
Changing a string to a float
Getting more information: type()
Type-conversion errors
What did you learn?
Test your knowledge
Try it out
Chapter 5 Input
input()
Putting the input on the same line
A shortcut for input() prompts
Inputting numbers
Using int() with input()
Input from the web
What did you learn?
Test your knowledge
Try it out
Chapter 6 GUIs: Graphical User Interfaces
What’s a GUI?
Our first GUI
Let’s get GUI-ing
GUI input
Pick your flavor
Dialog box with multiple buttons
Choice box
Text input
Default input
What about numbers?
The number guessing game … again
Other GUI pieces
What did you learn?
Test your knowledge
Try it out
Chapter 7 Decisions, Decisions
Testing, testing
Indenting
Am I seeing double?
Other kinds of tests
What happens if the test is false?
Testing for more than one condition
Using and
Using or
Using not
What did you learn?
Test your knowledge
Try it out
Chapter 8 Loop the Loop
Counting loops
Runaway loops
What are the square brackets for?
Using a counting loop
A shortcut: range()
A matter of style: Loop variable names
A range() shortcut
Counting by steps
Counting without numbers
While we’re on the subject …
Bailing out of a loop: break and continue
Jumping ahead: continue
Bailing out: break
What did you learn?
Test your knowledge
Try it out
Chapter 9 Just for You: Comments
Adding comments
Single-line comments
End-of-line comments
Multiline comments
Triple-quoted strings
Commenting style
Comments in this book
Commenting out
What did you learn?
Test your knowledge
Try it out
Chapter 10 Game Time
Skier
Try it out
Chapter 11 Nested and Variable Loops
Nested loops
Variable loops
Variable nested loops
Even more variable nested loops
Using nested loops
Counting calories
What did you learn?
Test your knowledge
Try it out
Chapter 12 Collecting Things Together: Lists and Dictionaries
What’s a list?
Creating a list
Adding things to a list
What’s the dot?
Lists can hold anything
Getting items from a list
Why does the index start at 0, not 1?
“Slicing” a list
Slice shorthand
Modifying items
Other ways of adding to a list
Adding to the end: append()
Extending the list: extend()
Inserting an item: insert()
The difference between append() and extend()
Deleting from a list
Deleting with remove()
Deleting with del
Deleting with pop()
Searching a list
The in keyword
Finding the index
Looping through a list
Sorting lists
Sorting in reverse order
Another way to sort: sorted()
Mutable and immutable
Tuple: An immutable list
Lists of lists: Tables of data
Getting a single value from the table
Dictionaries
A bit more about dictionaries
What did you learn?
Test your knowledge
Try it out
Chapter 13 Functions
Functions: The building blocks
Creating a function
Calling a function
Passing arguments to a function
Functions with more than one argument
How many is too many?
Functions that return a value
Returning a value
Variable scope
Local variables
Global variables
Forcing a global
A bit of advice on naming variables
What did you learn?
Test your knowledge
Try it out
Chapter 14 Objects
Objects in the real world
Objects in Python
What are attributes?
What are methods?
Object = attributes + methods
Creating objects
Creating an instance of an object
Initializing an object
A “magic” method: __str__()
What’s self?
An example class: HotDog
Hiding the data
Polymorphism and inheritance
Polymorphism: Same method, different behavior
Inheritance: Learning from your parents
Thinking ahead
What did you learn?
Test your knowledge
Try it out
Chapter 15 Modules
What’s a module?
Why use modules?
Buckets of blocks
How do we create modules?
How do we use modules?
Namespaces
What’s a namespace?
Importing namespaces
Importing using from
Whew!
Standard modules
Time
Random numbers
What did you learn?
Test your knowledge
Try it out
Chapter 16 Graphics
Getting some help: Pygame
A Pygame window
Drawing in the window
What’s the “flip”?
How to make a circle
Pygame surfaces
Colors in Pygame
Locations: Screen coordinates
Size of shapes
Line width
Modern art?
Individual pixels
Connect the dots
Connect the dots, again
Drawing point-by-point
Images
Let’s get moving!
Animation
Erasing images
What’s under there?
Smoother animation
Keeping the ball moving
Bouncing the ball
Bouncing in 2-D
Wrapping the ball
What did you learn?
Test your knowledge
Try it out
Chapter 17 Sprites and Collision Detection
Sprites
A sprite class
A move() method
Bump! Collision detection
Rect collision vs. pixel-perfect collision
Counting time
Controlling the frame rate with pygame.time.Clock()
Checking the frame rate
Scaling the frame rate
What did you learn?
Test your knowledge
Try it out
Chapter 18 A New Kind of Input: Events
Events
The event loop
The event queue
Event handlers
Keyboard events
Key events
Repeating keys
Event names and key names
Mouse events
Timer events
Time for another game—PyPong
The ball
The paddle
Controlling the paddle
Keeping score and displaying it with pygame.font
Keeping track of lives
Adding a life counter
Game over
What did you learn?
Test your knowledge
Try it out
Chapter 19 Sound
More help from Pygame: mixer
Making sounds vs. playing sounds
Playing sounds
Using pygame.mixer
Controlling volume
Playing background music
Repeating music
Adding sounds to PyPong
More wacky sounds
Adding music to PyPong
What did you learn?
Test your knowledge
Try it out
Chapter 20 More GUIs
Working with PyQt
Qt Designer
Adding a button
Changing the button
Saving the GUI
Making our GUI do something
The return of event handlers
What is self?
Moving the button
More useful GUIs
TempGUI
TempGUI components
Creating the new GUI
Converting Celsius to Fahrenheit
Converting Fahrenheit to Celsius
A small improvement
Squashing a bug
What’s on the menu?
Adding a menu item
Hotkeys
What did you learn?
Test your knowledge
Try it out
Chapter 21 Print Formatting and Strings
New lines
print and end=''
Adding our own newlines
Special printing codes
Horizontal spacing: Tabs
How do we print a backslash?
Inserting variables in strings
Number formatting
Integers: %d or %i
Floating point numbers: %f or %F
E-notation: %e and %E
Automatic float or E-notation: %g and %G
How do we print a percent sign?
More than one format string
Storing formatted numbers
Formatting, the new way
F-strings
Strings ’n’ things
Splitting strings
Joining strings
Searching for strings
Searching anywhere in a string: in and index()
Removing part of a string
Changing case
What did you learn?
Test your knowledge
Try it out
Chapter 22 File Input and Output
What’s a file?
Filenames
File locations
Finding where you are
Enough about paths!
Opening a file
Reading a file
Reading one line at a time
Going back to the start
Text files and binary files
Writing to a file
Appending to a file
Writing to a file using write mode
Writing to a file using print()
Saving your stuff in files: pickle
Pickling
Unpickling
Game time again—Hangman
The Hangman GUI
Getting words from the word list
Revealing the man
Checking the letter guesses
What did you learn?
Test your knowledge
Try it out
Chapter 23 Take a Chance: Randomness
What’s randomness?
Rolling the dice
More than one die
Ten in a row
Creating a deck of cards
Shuffling the deck
A card object
Crazy Eights
The main loop
The up card
The active suit
The player’s turn
Displaying the hand
Getting the player’s choice
The computer’s turn
Keeping score
What did you learn?
Test your knowledge
Try it out
Chapter 24 Computer Simulations
Modeling the real world
Lunar Lander
Simulating the landing
Pygame returns
Keeping time
Time objects
Difference between two times
Small pieces of time
Saving time to a file
Virtual Pet
The GUI
The algorithm
Simple animation
Try, try again
What did you learn?
Test your knowledge
Try it out
Chapter 25 Skier Explained
The skier
The obstacles
Creating individual obstacles
Creating a map of obstacles
What did you learn?
Try it out
Chapter 26 Making Network Connections with Sockets
What’s the difference between text and bytes?
Servers
Getting data from the client
Making a chat server
A little about IP addresses
Creating a chat client
What did you learn?
Test your Knowledge
Try it out
chapter 27 What’s Next?
For younger programmers
Python
Game programming and Pygame
Other game programming (non-Python)
Keep it BASIC
Websites
Mobile apps
Look around
APPENDIX A Variable Naming Rules
APPENDIX B Differences Between Python 3 and 2
print
input()
Integer division
range()
Bytes and character encodings
Python 2 to 3 conversion
APPENDIX C Answers to Self-Test Questions
Chapter 1: Getting Started
Test your knowledge
Try it out
Chapter 2: Remember This: Memory and Variables
Test your knowledge
Try it out
Chapter 3: Basic Math
Test your knowledge
Try it out
Chapter 4: Types of Data
Test your knowledge
Try it out
Chapter 5: Input
Test your knowledge
Try It Out
Chapter 6: GUIs: Graphical User Interfaces
Test your knowledge
Try it out
Chapter 7: Decisions, Decisions
Test your knowledge
Try it out
Chapter 8: Loop the Loop
Test your knowledge
Try it out
Chapter 9: Just for You—Comments
Try it out
Chapter 10: Game Time
Try it out
Chapter 11: Nested and Variable Loops
Test your knowledge
Try it out
Chapter 12: Collecting Things Together— Lists and Dictionaries
Test your knowledge
Try it out
Chapter 13: Functions
Test your knowledge
Try it out
Chapter 14: Objects
Test your knowledge
Try it out
Chapter 15: Modules
Test your knowledge
Try it out
Chapter 16: Graphics
Test your knowledge
Try it out
Chapter 17: Sprites and Collision Detection
Test your knowledge
Chapter 18: A New Kind of Input: Events
Test your knowledge
Try it out
Chapter 19: Sound
Test your knowledge
Try it out
Chapter 20: More GUIs
Test your knowledge
Try it out
Chapter 21: Print Formatting and Strings
Test your knowledge
Try it out
Chapter 22: File Input and Output
Test your knowledge
Try it out
Chapter 23: Take a Chance—Randomness
Test your knowledge
Try it out
Chapter 24: Computer Simulations
Test your knowledge
Try it out
Chapter 26: Making Network Connections with Sockets
Test your knowledge
Try it out
List of Code Listings
Index
Symbols
Math and comparison operators
Numerics
A
B
C
D
E
F
G
H
I
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Hello World! back