background preloader

Www.greenteapress.com/thinkpython/thinkCSpy/thinkCSpy.pdf

Www.greenteapress.com/thinkpython/thinkCSpy/thinkCSpy.pdf
Related:  Python Learning Resources

The Python Tutorial Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms. The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python Web site, and may be freely distributed. The Python interpreter is easily extended with new functions and data types implemented in C or C++ (or other languages callable from C). This tutorial introduces the reader informally to the basic concepts and features of the Python language and system. For a description of standard objects and modules, see The Python Standard Library. The Glossary is also worth going through.

Python Programming Python Programming From Wikibooks, open books for an open world Jump to: navigation, search This book describes Python, an open-source general-purpose interpreted programming language available for a broad range of operating systems. Contents[edit] Intro[edit] Overview Getting Python Setting it up Interactive mode Self Help Basics[edit] Creating Python programs Variables and Strings Basic syntax Sequences (Strings, Lists, Tuples, Dictionaries, Sets) Data types Numbers Strings Lists Tuples Dictionaries Sets Basic Math -- redundant to "Operators" Operators Control Flow Decision Control Conditional Statements Loops Functions Scoping Input and output Files Text Modules Classes Exceptions Errors Source Documentation and Comments Idioms Advanced[edit] Decorators Context Managers Reflection Metaclasses Namespace Tips and Tricks Modules[edit] Standard library modules[edit] Standard Library Regular Expression External commands XML Tools Email Threading Sockets GUI Programming Tkinter CGI interface WSGI web programming Extracting info from web pages Math

PythonTurtle A Python Book: Beginning Python, Advanced Python, and Python Exercises 2.2 Regular Expressions For more help on regular expressions, see: 2.2.1 Defining regular expressions A regular expression pattern is a sequence of characters that will match sequences of characters in a target. The patterns or regular expressions can be defined as follows: Literal characters must match exactly. Because of the use of backslashes in patterns, you are usually better off defining regular expressions with raw strings, e.g. r"abc". 2.2.2 Compiling regular expressions When a regular expression is to be used more than once, you should consider compiling it. import sys, re pat = re.compile('aa[bc]*dd') while 1: line = raw_input('Enter a line ("q" to quit):') if line == 'q': break if pat.search(line): print 'matched:', line else: print 'no match:', line Comments: We import module re in order to use regular expresions.re.compile() compiles a regular expression so that we can reuse the compiled regular expression without compiling it repeatedly. 2.2.3 Using regular expressions Notes:

Python Introduction - Google's Python Class - Google Code Python is a dynamic, interpreted language. Source code does not declare the types of variables or parameters or methods. This makes the code short and flexible, and you lose the compile-time type checking in the source code. An excellent way to see how Python code works is to run the Python interpreter and type code right into it. $ python ## Run the Python interpreterPython 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> a = 6 ## set a variable in this interpreter session >>> a ## entering an expression prints its value6>>> a + 28>>> a = 'hi' ## a can hold a string just as well>>> a 'hi'>>> len(a) ## call the len() function on a string2>>> foo(a) ## try something that doesn't workTraceback (most recent call last): File " Python Program Python source files use the ".py" extension. #! Running this program from the command line looks like:

Hands-On Python A Tutorial Introduction for Beginners Hands-On Python A Tutorial Introduction for Beginners Contents Chapter 1Beginning With Python 1.1. Context 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

Python In One Easy Lesson Nick Parlante Nov 2010 This is a one-hour introduction to Python used for Stanford's CS107. This material should work as an introduction for any experienced programmer. We'll look at some core Python features and get a feel for how it compares to other languages. For a longer introduction to Python by the same author with videos and exercises, see Google's Python Class. Python is a popular open source, cross-platform language in the "dynamic language" niche, like Javascript, Ruby, Lisp, and Perl. Unlike C/C++, Python defers almost everything until runtime. This is how Python works, in contrast to the C/C++ style of knowing the type of every variable and using that for compile time code generation. x = x + x In Python, x could be an int, or a string, or who knows what. Interpreter and Variables You can run the Python interpreter and type code directly in to it -- a good way to try little experiments. Strings Strings are delimited with ' or " or """, and are immutable. Lists [ ], For Loop #!

An Introduction to Interactive Programming in Python About this course: This two-part course is designed to help students with very little or no computing background learn the basics of building simple interactive applications. Our language of choice, Python, is an easy-to learn, high-level computer language that is used in many of the computational courses offered on Coursera. To make learning Python easy, we have developed a new browser-based programming environment that makes developing interactive applications in Python simple. These applications will involve windows whose contents are graphical and respond to buttons, the keyboard and the mouse.

Dive Into Python

Related: