Books & Videos

Table of Contents

  1. Chapter 1 Starting to Code: Finding your way

    1. Programming lets you do more

    2. So how do you run your code?

    3. Create a new program file

    4. Prepare and run your code

    5. A program is more than a list of commands

    6. Codeville: Your program is like a network of roads

    7. Branches are code intersections

    8. if/else branches

    9. The Python code needs interconnecting paths

    10. Python uses indents to connect paths

    11. Loops let you run the same piece of code over and over again

    12. Python’s while loop

    13. Your Programming Toolbox

  2. Chapter 2 Textual Data: Every string has its place

    1. Your new gig at Starbuzz Coffee

    2. Here’s the current Starbuzz code

    3. The cost is embedded in the HTML

    4. A string is a series of characters

    5. Find characters inside the text

    6. But how do you get at more than one character?

    7. Beans‘R’Us is rewarding loyal customers

    8. Searching is complex

    9. Python data is smart

    10. Strings and numbers are different

    11. The program has overloaded the Beans’R’Us Server

    12. Time... if only you had more of it

    13. You’re already using library code

    14. Order is restored

    15. Your Programming Toolbox

  3. Chapter 3 Functions: Let’s get organized

    1. Starbuzz is out of beans!

    2. What does the new program need to do?

    3. Don’t duplicate your code...

    4. ...Reuse your code instead

    5. Reuse code with functions

    6. Always get things in the right order

    7. Return data with the return command

    8. Use the Force, Web Luke

    9. The function always sends the same message

    10. Use parameters to avoid duplicating functions

    11. Someone decided to mess with your code

    12. The rest of the program can’t see the password variable

    13. When you call a function, the computer creates a fresh list of variables

    14. When you leave a function, its variables get thrown away

    15. Starbuzz is fully stocked!

    16. Your Programming Toolbox

  4. Chapter 4 Data in Files and Arrays: Sort it out

    1. Surf’s up in Codeville

    2. Find the highest score in the results file

    3. Iterate through the file with the open, for, close pattern

    4. The file contains more than numbers...

    5. Split each line as you read it

    6. The split() method cuts the string

    7. But you need more than one top score

    8. Keeping track of 3 scores makes the code more complex

    9. An ordered list makes code much simpler

    10. Sorting is easier in memory

    11. You can’t use a separate variable for each line of data

    12. An array lets you manage a whole train of data

    13. Python gives you arrays with lists

    14. Sort the array before displaying the results

    15. Sort the scores from highest to lowest

    16. And the winner is...?

    17. You somehow forgot the surfer names

    18. Your Programming Toolbox

  5. Chapter 5 Hashes and Databases: Putting data in its place

    1. Who won the surfing contest?

    2. Associate the name with the score

    3. Associate a key with a value using a hash

    4. Iterate hash data with for

    5. The data isn’t sorted

    6. When data gets complex

    7. Return a data structure from a function

    8. Here’s your new board!

    9. Meanwhile, down at the studio...

    10. The code remains the same; it’s the function that changes

    11. TVN’s data is on the money!

    12. Your Programming Toolbox

  6. Chapter 6 Modular Programming: Keeping things straight

    1. Head First Health Club is upgrading some systems

    2. The program needs to create a transaction file

    3. Use strings to format strings

    4. A late night email ruins your day

    5. $50,000... for a donut?!

    6. Only the sales from your program were rejected

    7. The new bank uses a new format

    8. Your coffee bar program still uses the old format

    9. Don’t just update your copy

    10. So how do you create a module...?

    11. The transaction file is working great, too

    12. The health club has a new requirement

    13. The Starbuzz code

    14. The two discount functions have the same name

    15. Fully Qualified Names (FQNs) prevent your programs from getting confused

    16. The discounts get the customers flooding in

    17. Your Programming Toolbox

  7. Chapter 7 Building a Graphical User Interface: Going all gooey

    1. Head First TVN now produces game shows

    2. pygame is cross platform

    3. 0... 2... 1... 9... blast off!

    4. tkinter gives you the event loop for free

    5. tkinter is packed with options

    6. The GUI works, but doesn’t do anything

    7. Connect code to your button events

    8. The GUI program’s now ready for a screentest

    9. But TVN is still not happy

    10. Label it

    11. Your Programming Toolbox

  8. Chapter 8 Guis and Data: Data entry widgets

    1. Head-Ex needs a new delivery system

    2. They’ve already designed the interface

    3. Read data from the GUI

    4. The Entry and Text widgets let you enter text data into your GUI

    5. Read and write data to text fields

    6. Large Text fields are harder to handle

    7. One of the Head-Ex deliveries went astray

    8. Users can enter anything in the fields

    9. Radio buttons force users to choose a valid depot

    10. Creating radio buttons in tkinter

    11. The radio buttons should work together

    12. The radio buttons can share a model

    13. The system tells the other widgets when the model changes

    14. So how do you use models in tkinter?

    15. Head-Ex’s business is expanding

    16. There are too many depots on the GUI

    17. An OptionMenu lets you have as many options as needed

    18. The model stays the same

    19. Things are going great at Head-Ex

    20. Your Programming Toolbox

  9. Chapter 9 Exceptions and Message Boxes: Get the message?

    1. What’s that smell?

    2. Someone changed the file permissions

    3. When it couldn’t write to the file, the program threw an exception

    4. Catch the exception

    5. Watch for exceptions with try/except

    6. There’s an issue with the exception handler

    7. A message box demands attention

    8. Creating message boxes in Python

    9. Your Programming Toolbox

  10. Chapter 10 Graphical Interface Elements: Selecting the right tool

    1. Time to mix it up

    2. The music just kept on playing...

    3. Not all events are generated by button clicks

    4. Controlling the Window Manager

    5. Capturing the protocol event isn’t enough

    6. Two buttons, or not two buttons? That is the question...

    7. The checkbox is an on/off, flip/flop toggle

    8. Working with checkboxes in tkinter

    9. Pump up the volume!

    10. Model a slider on a scale

    11. Use pygame to set the volume

    12. Use tkinter for everything else

    13. The DJ is over the moon!

    14. Your Programming Toolbox

  11. Chapter 11 Custom Widgets and Classes: With an object in mind

    1. The DJ wants to play more than one track

    2. Create code for each track as a function

    3. The new function contains other functions

    4. Your new function needs to create widgets and event handlers

    5. The DJ is confused

    6. Group widgets together

    7. A frame widget contains other widgets

    8. A class is a machine for creating objects

    9. A class has methods that define behavior

    10. But how does an object call a method?

    11. The SoundPanel class looks a lot like the create_gui() function

    12. class = methods + data

    13. The DJ has an entire directory of tracks

    14. It’s party time!

    15. Your Programming Toolbox

    16. Leaving town...

    17. It’s been great having you here in Codeville!

  1. Appendix Leftovers: The Top Ten Things (we didn’t cover)

    1. #1: Doing things “The Python Way”

    2. #2: Using Python 2

    3. #3: Other programming languages

    4. #4: Automated testing techniques

    5. #5: Debugging

    6. #6: Command-line execution

    7. #7: Ooops... we could’ve covered more OOP

    8. #8: Algorithms

    9. #9: Advanced Scary programming topics

    10. #10: Other IDEs, shells, and text editors