A Smarter Way To Learn Python | Learn It Faster & Remember It Longer!

This isn’t a book quite like any you’ve ever owned before, so a brief user manual might be helpful.

Study, practice, then rest. If you’re intent on mastering the fundamentals of Python, as opposed to just getting a feel for the language, work with this book and the online exercises in a 15-to-25- minute session, then take a break. Study a chapter for 5 to 10 minutes. Immediately go to the online link given at the end of each chapter and code for 10 to 15 minutes, practicing the lesson until you’ve coded everything correctly. Then take a walk.

Do the coding exercises on a physical keyboard. A mobile device can be ideal for reading, but it’s no way to code. Very, very few Web developers would attempt to do their work on a phone. The same thing goes for learning to code. Theoretically, most of the interactive exercises could be done on a mobile device. But the idea seems so perverse that I’ve disabled online practice on tablets, readers, and phones.

If you have an authority problem, try to get over it. When you start doing the exercises, you’ll find that I can be a pain about insisting that you get every little detail right. For example, if you omit spaces where spaces belong, the program monitoring your work will tell you the code isn’t correct, even though it might still run perfectly. Do I insist on having everything just so because I’m a control freak? No, it’s because I have to place a limit on harmless maverick behavior in order to automate the exercises. If I were to grant you as much freedom as you might like, creating the algorithms that check your work would be, for me, a project of frightening proportions. Besides, learning to write code with fastidious precision helps you learn to pay close attention to details, a fundamental requirement for coding in any language.

Subscribe, temporarily, to my formatting biases. Current code formatting is like seventeenth-century spelling. Everyone does it his own way. There are no universally accepted standards. But the
algorithms that check your work when you do the interactive exercises need standards. They can’t grant you the latitude that a human teacher could, because, let’s face it, algorithms aren’t that bright. So I’ve had to settle on certain conventions. All of the conventions I teach are embraced by a large segment of the coding community, so you’ll be in good company. But that doesn’t mean you’ll be married to my formatting biases forever. When you start coding projects, you’ll soon develop your own opinions or join an organization that has a stylebook. Until then, I’ll ask you to make your code look like my code.

Table of Contents

  • Learn it faster. Remember it longer.
  • How to use this book
  • The language you’re learning here
  • 1: print
  • 2: Variables for Strings
  • 3: Variables for Numbers
  • 4: Math expressions: Familiar operators
  • 5: Variable Names Legal and Illegal
  • 6: Math expressions: Unfamiliar operators
  • 7: Math expressions: Eliminating ambiguity
  • 8: Concatenating text strings
  • 9: if statements
  • 10: Comparison operators
  • 11: else and elif statements
  • 12: Testing sets of conditions
  • 13: if statements nested
  • 14: Comments
  • 15: Lists
  • 16: Lists: Adding and changing elements
  • 17: Lists: Taking slices out of them
  • 18: Lists: Deleting and removing elements
  • 19: Lists: popping elements
  • 20: Tuples
  • 21: for loops
  • 22: for loops nested
  • 23: Getting information from the user and converting strings and
  • numbers
  • 24: Changing case
  • 25: Dictionaries: What they are
  • 26: Dictionaries: How to code one
  • 27: Dictionaries: How to pick information out of them
  • 28: Dictionaries: The versatility of keys and values
  • 29: Dictionaries: Adding items
  • 30: Dictionaries: Removing and changing items
  • 31: Dictionaries: Looping through values
  • 32: Dictionaries: Looping through keys
  • 33: Dictionaries: Looping through key-value pairs
  • 34: Creating a list of dictionaries
  • 35: How to pick information out of a list of dictionaries
  • 36: How to append a new dictionary to a list of dictionaries
  • 37: Creating a dictionary that contains lists
  • 38: How to get information out of a list within a dictionary
  • 39: Creating a dictionary that contains a dictionary
  • 40: How to get information out of a dictionary within another dictionary
  • 41: Functions
  • 42: Functions: Passing them information
  • 43: Functions: Passing information to them a different way
  • 44: Functions: Assigning a default value to a parameter
  • 45: Functions: Mixing positional and keyword arguments
  • 46: Functions: Dealing with an unknown number of arguments
  • 47: Functions: Passing information back from them
  • 48: Using functions as variables (which is what they really are)
  • 49: Functions: Local vs. global variables
  • 50: Functions within functions
  • 51: While loops
  • 52: While loops: Setting a flag
  • 53: Classes
  • 54: Classes: Starting to build the structure
  • 55: Classes: A bit of housekeeping
  • 56: Classes: Creating an instance
  • 57: Classes: A little more complexity
  • 58: Classes: Getting info out of instances
  • 59: Classes: Building functions into them
  • 60: Classes: Coding a method
  • 61: Classes: Changing an attribute’s value
  • 62: Data files
  • 63: Data files: Storing data
  • 64: Data files: Retrieving data
  • 65: Data files: Appending data
  • 66: Modules
  • 67: CSV files
  • 68: CSV files: Reading them
  • 69: CSV files: Picking information out of them
  • 70: CSV files: Loading information into them. Part 1
  • 71: CSV files: Loading information into them. Part 2
  • 72: CSV files: Loading information into them. Part 3
  • 73: CSV files: Appending rows to them.
  • 74: How to save a Python list or dictionary in a file: JSON
  • 75: How to retrieve a Python list or dictionary from a JSON file
  • 76: Planning for things to go wrong
  • 77: A more practical example of exception handling
  • Guide to the appendices

Download PDF

Happy learning!


Sololearn is a similar app


Thank you for sharing @TheStrength, Cool!

1 Like

Here it is: