Log In
Or create an account -> 
Imperial Library
  • Home
  • About
  • News
  • Upload
  • Forum
  • Help
  • Login/SignUp

Index
Praise for Head First Learn to Code Praise for other books by Eric Freeman Head First Learn to Code   the author Table of Contents (the real thing) 1. how to use this book: Intro
Who is this book for?
Who should probably back away from this book?
We know what you’re thinking.
And we know what your brain is thinking.
This must be important! Don’t forget it!
Metacognition: thinking about thinking
So how DO you get your brain to think coding is as important as a tiger?
Here’s what WE did: Here’s what YOU can do to bend your brain into submission Read Me
We want you to learn the thinking process behind programming. In this book we use Python. We don’t exhaustively cover every aspect of the Python language. You can use a Mac or PC, or Linux for that matter. The activities are NOT optional. The redundancy is intentional and important. The examples are as lean as possible. The Brain Power exercises don’t usually have answers. Get the code examples, help, and discussion online.
You’re going to have to install Python A word on organizing your code Acknowledgments* The Review Team
2. 1 thinking computationally: Getting Started
Breaking it down How coding works Are we even speaking the same language? The world of programming languages How you’ll write and run code with Python
there are no Dumb Questions
A very brief history of Python Putting Python through its paces Saving your work Congrats on coding your first Python program!
there are no Dumb Questions
Phrase-O-Matic Getting the code in the machine
3. 2 simple values, variables, and types: Know Your Value
Coding the Dog Age Calculator Going from pseudocode to code Step 1: Getting some input How the input function works Using variables to remember and store values Assigning the user’s input to a variable Step 2: Getting more input It’s time to run some code Getting some code entered A deep dive on variables Adding some expression Variables are called VARY-ables for a reason Better living through operator precedence Computing with operator precedence Crack the Code Challenge Back away from that keyboard!
there are no Dumb Questions
Step 3: Computing the dog’s age Houston, we’ve got a problem! To err is human to code A little more debugging...
Careful what you ask for...
What are Python types, anyway?
there are no Dumb Questions
Fixing our code
there are no Dumb Questions
Houston, we have liftoff Step 4: User-friendly output
Who am I? Solution
Crack the Code Challenge SOLUTION
4. 3 booleans, decisions, and loops: Decisive Code
Would you like to play a game?
How Rock, Paper, Scissors works How you’re going to play against the computer
First, a high-level design The computer’s choice
How to generate a random number
How to use the random number
there are no Dumb Questions
Taking things further... True? Or False? Introducing the Boolean type Making decisions Decisions and more decisions Back to Rock, Paper, Scissors Getting the user’s choice
Good eye.
Taking a look at the user’s choice Adding the code to detect a tie Who won?
Right.
How to implement the game logic More about Boolean operators Display the winner Got documentation? How to add comments to your code We need to finish that game! How do we know if the user’s choice is invalid? Checking out and cleaning up the expression How to continually prompt the user Doing things more than once How the while loop works How to use while to prompt the user until you get a valid choice Congratulations on coding your first game!
Beware of the The Dreaded Infinite Loop
5. 4 lists and iteration: Providing Some Structure
Can you help Bubbles-R-Us? How to represent multiple values in Python How lists work
How to create a list How to access a list item Updating a value in the list
How big is that list, anyway? Accessing the last item in the list Python makes this even easier Using Python’s negative indices
there are no Dumb Questions
Meanwhile, back at Bubbles-R-Us... Cubicle conversation How to iterate over a list Fixing the output glitch Really fixing the output glitch The for loop, the preferred way to iterate over a list
How the for loop works
How the for loop works on a range of numbers Doing more with ranges
Try a starting and ending number Add a step size Count backward Or start from negative numbers there are Dumb Questions
Putting it all together Test drive the bubble report
Fireside Chats
Cubicle conversation continued... Building your own list, from scratch Doing even more with lists
Delete an item from a list Add one list to another Or insert items into your list there are no Dumb Questions
Test drive the final report And the winners are... Testing the most cost-effective solution
You’re right: we didn’t need to.
6. 5 functions and abstraction: Getting Functional
What’s wrong with the code, anyway? Turning a block of code into a FUNCTION We created a function, so how do we use it? But how does all this actually work?
there are no Dumb Questions
Functions can RETURN things too How to call a function that has a return value
Good catch.
Getting a little refactoring under our belts Running the code How to abstract the avatar code Writing the get attribute function body Calling get attribute Let’s talk about variables a little more... Understanding variable scope
there are no Dumb Questions
When variables get passed to functions Making the drink_me function call What about using global variables in functions?
Fireside Chats
Going further with parameters: default values and keywords How default parameter values work Always list your required parameters first! Using arguments with keywords How to think about all these options
The case of the attempted robbery not worth investigating
7. 4, part 2, sorting and nested iteration: Putting Some Order in Your Data
Cubicle conversation Understanding bubble sort Starting with pass 1 Pass 2 Pass 3 Some bubble sort pseudocode Cubicle conversation continued... Implementing bubble sort in Python Computing bubble solution numbers
8. 6 text, strings, and heuristics: Putting It All Together
Welcome to the data sciences How do you compute something like readability? The game plan Writing some pseudocode We need some text to analyze
How to get multiline text into Python
Setting up the function First up: we need the total number of words in our text Cubicle conversation
there are no Dumb Questions
Computing the total number of sentences Writing the count_sentences function Computing the number of syllables, or, learning to love heuristics Cubicle conversation continued... Setting up the heuristic Writing the heuristic How to count vowels Ignoring consecutive vowels Writing the code to ignore consecutive vowels Removing final e’s, y’s, and punctuation
He who controls the slice, controls the...
Putting slicing (substrings) to work Finishing off the heuristic code Implementing the reading ease formula Taking it even further
9. 7 modules, methods, classes, and objects: Getting Modular
Cubicle conversation A quick module review
there are no Dumb Questions
Cubicle conversation continued... The name global variable Cubicle conversation continued... Updating analyze.py Using analyze.py as a module Adding docstrings to analyze.py Exploring other Python modules Wait, did someone say “turtles”?! Creating your very own turtle Turtle lab
there are no Dumb Questions
Adding a second turtle What are turtles, anyway? What are objects? Okay, what’s a class then?
A class is not an object, it’s used to construct them. there are no Dumb Questions
A class tells us what an object knows and what an object can do How to use objects and classes What about those methods and attributes? Seeing classes and objects everywhere Get ready for some turtle races Planning the game Let’s start coding Setting up the game Writing the setup code Not so fast! Starting the race Don’t worry, this isn’t the end of objects.
Odd goings-on at the turtle races.
Mod coding cross Mod cross Solution
10. 8 recursion and dictionaries: Beyond Iteration and Indices
A different way to compute And now the different way... Now let’s write some code for our two cases Let’s get some more practice Using recursion to detect palindromes Writing a recursive palindrome detector
there are no Dumb Questions Fireside Chats
The Anti-Social Network Introducing the dictionary Let’s see how to create a dictionary And then add items And then retrieve values by their keys Keys and values do not have to be strings Of course you can remove keys as well But you might want to test to see if it exists first
there are no Dumb Questions
What about iterating through a dictionary? Okay, but can we get literal for a sec? Leveraging dictionaries at the Anti-Social Network But how do we add more attributes? Remember the Anti-Social Network’s killer feature? Finding the most anti-social user Now, it’s all you! Can we just remember function call results? Using a dictionary to remember our Fibonacci results We might as well use the $5 words: memoization Some more brain building A closer look at the koch function Truly exploring the koch fractal They don’t call it the Koch snowflake for nothin’
11. 9 saving and retrieving files: Persistence
Ready for some Crazy Libs?
How to Play
How Crazy Libs is going to work Step 1: Read the text of the story from a file To read a file in Python, you first have to open it How to use file paths Relative paths Absolute paths Oh, and don’t forget to clean up when you’re done! Reading a file into your Python code Using the file object to read a file Oh, give it a break already... Hey, we’ve got a Crazy Lib game to finish! Using the readline method of the file object How do we know when we’ve read the last line? Ah, but there’s a easier way using the power of Python sequences Reading in a Crazy Lib template Processing the template text Now let’s process the text Using a new string method to fix the bug Actually fixing the bug Some code has real problems Handling exceptions Explicitly handling exceptions
there are Dumb Questions
Updating Crazy Libs to handle exceptions Our last step: storing the Crazy Lib Updating the rest of the code File i/o cross Solution
12. 10 using web apis: You Really Should Get Out More
Extending your reach with Web APIs How Web APIs work All Web APIs have a web address
Consult the API documentation. Good point.
Time for a quick upgrade Doing the upgrade
there are no Dumb Questions
All we need now is a good Web API... A closer look at the API Web APIs provide data using JSON
there are no Dumb Questions
Now let’s look at that request module again Putting it all together: making a request to Open Notify How to use JSON in Python Using the JSON module on our ISS data Let’s add some graphics Meet the screen object Let’s add a turtle to represent the ISS Turtles can look like space stations too Forget the ISS—where are we? Finishing off the ISS code
13. 11 widgets, events, and emergent behavior: Getting Interactive
A closer look at the Game of Life
Oh, you’d be surprised...
What we’re going to build Do we have the right design? How we’re going to build the simulator Building the data model Representing the grid Computing a generation of the Game of Life Computing each cell’s fate Completing the model code Where are we? Building the view Creating your first widget Adding the rest of the widgets Correcting the layout Placing the widgets into a grid layout Translating the grid layout to code
there are no Dumb Questions
Moving on to the controller Adding an update function
there are no Dumb Questions
Ready for another new style of computation? Let’s add a click handler How the start/pause button is going to work Implementing the start/pause button Another kind of event We have the technology: the after method Are we there yet? How to enter and edit cells directly Writing the grid_view handler Now it’s time to add some patterns Writing a handler for the OptionMenu How to define your patterns Writing the pattern loader
14. 12 object-oriented programming: A Trip to Objectville
Breaking it down, a different way What’s the point of object-oriented programming, anyway? Designing your first class Writing your first class How the constructor works
there are no Dumb Questions
Writing the bark method How methods work Adding some inheritance Implementing the ServiceDog class A closer look at subclassing A ServiceDog IS-A Dog Testing IS-A in code How would you describe yourself?
there are no Dumb Questions
Overriding and extending behavior Welcome to Jargon City Object can HAS-Another object Designing a Doggie Hotel Implementing the Doggie Hotel Renovating the Doggie Hotel Adding some hotel activities I can do anything you can, or Polymorphism It’s about time we teach the other dogs to walk The power of inheritance Creating a Doggie Hotel walking service How are we going to hire a person to walk our dogs if we don’t even have people objects?
Meanwhile, back at the turtle races… The turtle races case SOLVED Have you considered a career in coding?
A. appendix: leftovers: The Top Ten Topics (We Didn’t Cover)
#1 List comprehensions #2 Dates and times #3 Regular expressions #4 Other data types: tuples #5 Other data types: sets #6 Server-side coding #7 Lazy evaluation #8 Decorators #9 Higher-order and first-class functions #10 A lot of libraries
Don’t worry, this isn’t goodbye.
B. Bring your brain over to wickedlysmart.com Index
Symbols A B C D E F G H I J K L M N O P Q R S T U V W Y Z
  • ← Prev
  • Back
  • Next →
  • ← Prev
  • Back
  • Next →

Chief Librarian: Las Zenow <zenow@riseup.net>
Fork the source code from gitlab
.

This is a mirror of the Tor onion service:
http://kx5thpx2olielkihfyo4jgjqfb7zx7wxr3sd4xzt26ochei4m6f7tayd.onion