background preloader

Python 2.x How to Think Like a Computer Scientist — Learning with Python 2nd Edition

Python 2.x How to Think Like a Computer Scientist — Learning with Python 2nd Edition
Navigation How to Think Like a Computer Scientist¶ Learning with Python¶ 2nd Edition (Using Python 2.x) by Jeffrey Elkner, Allen B. Last Updated: 21 April 2012 Copyright NoticeForewordPrefaceContributor ListChapter 1 The way of the programChapter 2 Variables, expressions, and statementsChapter 3 FunctionsChapter 4 ConditionalsChapter 5 Fruitful functionsChapter 6 IterationChapter 7 StringsChapter 8 Case Study: CatchChapter 9 ListsChapter 10 Modules and filesChapter 11 Recursion and exceptionsChapter 12 DictionariesChapter 13 Classes and objectsChapter 14 Classes and functionsChapter 15 Classes and methodsChapter 16 Sets of ObjectsChapter 17 InheritanceChapter 18 Linked ListsChapter 19 StacksChapter 20 QueuesChapter 21 TreesAppendix A DebuggingAppendix B GASPAppendix c Configuring Ubuntu for Python DevelopmentAppendix D Customizing and Contributing to the BookGNU Free Document License Search Page © Copyright 2010, Jeffrey Elkner, Allen B.

python3 How to Think Like a Computer Scientist — How to Think Like a Computer Scientist: Learning with Python 3 Version date: October 2012 by Peter Wentworth, Jeffrey Elkner, Allen B. Downey, and Chris Meyers (based on 2nd edition by Jeffrey Elkner, Allen B. Corresponding author: p.wentworth@ru.ac.za Source repository is at For offline use, download a zip file of the html or a pdf version (the pdf is updated less often) from Search PageCopyright NoticeForewordPrefacePreface-3 This Rhodes Local Edition (RLE) of the bookContributor ListChapter 1 The way of the programChapter 2 Variables, expressions, and statementsChapter 3 Hello, little turtles! News PEP 8 -- Style Guide for Python Code Code should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such).For example, do not rely on CPython's efficient implementation of in-place string concatenation for statements in the form a += b or a = a + b. This optimization is fragile even in CPython (it only works for some types) and isn't present at all in implementations that don't use refcounting. In performance sensitive parts of the library, the ''.join() form should be used instead. This will ensure that concatenation occurs in linear time across various implementations.Comparisons to singletons like None should always be done with is or is not, never the equality operators.Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context!

Become a Programmer, Motherfucker If you don't know how to code, then you can learn even if you think you can't. Thousands of people have learned programming from these fine books: Learn Python The Hard Way Learn Ruby The Hard Way Learn Code The Hard Way I'm also working on a whole series of programming education books at learncodethehardway.org. Learn C The Hard Way Learn SQL The Hard Way Graphics Programming Language Agnostic NerdDinner Walkthrough Assembly Language Bash Clojure Clojure Programming ColdFusion CFML In 100 Minutes Delphi / Pascal Django Djangobook.com Erlang Learn You Some Erlang For Great Good Flex Getting started with Adobe Flex (PDF) Forth Git Grails Getting Start with Grails Haskell Java JavaScript JavaScript (Node.js specific) Latex The Not So Short Introduction to LATEX (perfect for beginners) Linux Advanced Linux Programming Lisp Lua Programming In Lua (for v5 but still largely relevant)Lua Programming Gems (not entirely free, but has a lot of free chapters and accompanying code) Maven Mercurial Nemerle Nemerle NoSQL Oberon Objective-C

labs :: 10 Python pitfalls (or however many I'll find ;-) These are not necessarily warts or flaws; rather, they are (side effects of) language features that often trip up newbies, and sometimes experienced programmers. Incomplete understanding of some core Python behavior may cause people to get bitten by these. This document is meant as some sort of guideline to those who are new to Python. 1. OK, this is a cheesy one to start with. Solution: Indent consistently. 2. People coming from statically typed languages like Pascal and C often assume that Python variables and assignment work the same as in their language of choice. a = b = 3 a = 4 print a, b # 4, 3 However, then they run into trouble when using mutable objects. a = [1, 2, 3] b = a a.append(4) print b # b is now [1, 2, 3, 4] as well The idea that mutable and immutable objects are treated differently when doing assignment, is incorrect. Solution: Read this. 3. x += 42; is syntactic sugar for x = x + 42; So, you might think that it's the same in Python. 4. and

James Somers – Web developer money There’s this great moment in the documentary Jiro Dreams of Sushi (2011) when the world’s most celebrated sushi chef turns to his son, who is leaving to start his own restaurant, and says: ‘You have no home to come back to.’ Which, when you think about it, isn’t harsh or discouraging but is in fact the very best thing you could say to someone setting out on an adventure. Last October I quit my job to become a freelance journalist. My plan was to sell that profile and keep writing others like it. Get Aeon straight to your inbox My new life began on a Monday. When, in 1958, Ernest Hemingway was asked: ‘What would you consider the best intellectual training for the would-be writer?’ Let’s say that he should go out and hang himself because he finds that writing well is impossibly difficult. I worked on my Hofstadter piece until early Thursday afternoon. I put my adventure on hold. In college I sort of aimlessly played. I didn’t think finding good work would be this easy.

labs :: Python beginner's mistakes Every Python programmer had to learn the language at one time, and started out as a beginner. Beginners make mistakes. This article highlights a few common mistakes, including some I made myself. Beginner's mistakes are not Python's fault, nor the beginner's. To put it another way, the mistakes in this article are often cases of "the wrong tool for the job", rather than coding errors or sneaky language traps. Mistake 1: trying to do low-level operations Python is sometimes described as a VHLL, a Very High-Level Language. This doesn't mean that it isn't possible to do these things with Python; but it's probably just not the right language for these jobs. Mistake 2: writing "language X" code in Python This is a mistake that is almost unavoidable. Some notorious symptoms of "language X" code, and the languages that may cause them: The point here is not to slam the language that you're used to (although that is always fun ;-). This one requires some clarification. Some advice

For learning, refreshing, or just for fun! Hands-On Python A Tutorial Introduction for Beginners Hands-On Python A Tutorial Introduction for Beginners Contents Chapter 1 Beginning With Python 1.1. You have probably used computers to do all sorts of useful and interesting things. 1.1.1. First let us place Python programming in the context of the computer hardware. z = x+y is an instruction in many high-level languages that means something like: Access the value stored at a location labeled x Calculate the sum of this value and the value stored at a location labeled y Store the result in a location labeled z. No computer understands the high-level instruction directly; it is not in machine language. Obviously high-level languages were a great advance in clarity! If you follow a broad introduction to computing, you will learn more about the layers that connect low-level digital computer circuits to high-level languages. 1.1.2. There are many high-level languages. 1.1.3. If you are not sure whether your computer already has Python, continue to Section 1.2.2 , and give it a try. Windows Linux 1.2.

Related: