1. and
    Logical AND operator
  2. del
    Deletes objects. These objects could be local variables.
  3. from
    Used for importing elements from modules
  4. not
    The logical NOT operation
  5. while
    Used for looping until the conditions in while remains true
  6. as
    When used with the 'import' statement, the as keyword is used to name the bound object. It can also be used with the 'with' statement.
  7. elif
    Else if
  8. global
    This causes a local variable to be visible outside of its scope
  9. or
    The logical OR operation
  10. with
    This seems like a more convenient alternative to try, when there is a setup, execution and teardown cycle to be performed.
  11. assert
    The 'assert' statement is used to put error checking in your code.
  12. else
    'else' part of a conditional
  13. pass
    The 'pass' statement does nothing. It is used when a statement is required syntactically, but nothing needs to be done.
  14. yield
    The yield statement causes a function to return a generator. When this generator is run, it will return a value specified by the yield statement and will do so every time it is run until the function runs out of values. This is also akin to continuations.
  15. break
    The 'break' statement breaks out of the immediately enclosing 'for' or 'while' loop
  16. except
    The 'except' keyword is used as a counterpart to the 'try' keyword and it is used to raise exceptions.
  17. import
    Used for importing modules and their elements
  18. print
    Used for printing something to the console
  19. class
    Used for defining a class
  20. exec
    Supports dynamic executions of Python code. object must be either a string or a code object. If it is a string, the string is parsed as a suite of Python statements which is then executed (unless a syntax error occurs). If it is a code object, it is simply executed.
  21. in
    The inclusion operator
  22. raise
    • If no expressions are present, raise re-raises the last exception that was active in the current scope. If no exception is active in the current scope, a TypeError exception is raised indicating that this is an error (if running under IDLE, a Queue.Empty exception is raised instead).
    • This can also be used to create user defined exceptions
  23. continue
    Continue back to the start of the loop. It is used to interrupt the current cycle, without jumping out of the whole cycle. New cycle will begin.
  24. finally
    • A finally clause is always executed before leaving the try statement, whether an exception has occurred or not. When an exception has occurred in the try clause and has not been handled by an except clause (or it has occurred in a except or else clause), it is re-raised after the finally clause has been executed. The finally clause is also executed “on the way out” when any other clause of the try statement is left via a break, continue or return statement.
    • In real world applications, the finally clause is useful for releasing external resources (such as files or network connections), regardless of whether the use of the resource was successful.
  25. is
    • Used to determine if two values are stored in the same memory location. Never use "is" unless you want to check "if something is None or something is not None"
    • Is is identity, not equality. It's the equivalent of comparing two pointers' addresses in C. You can get the memory location of an object x in python using the id() function, so remember the following: a is b IS THE SAME THING AS id(a) == id(b)
    • The reason 'is' works for things like 'a is None' is because there is only one None builtin in memory ever, all the variables assigned to none merely point at it.
  26. return
    Used to return a value from a function
  27. def
    Keyword used to define a function
  28. for
    The for loop
  29. lambda
    • Used to create small anonymous functions
    • By popular demand, a few features commonly found in functional programming languages like Lisp have been added to Python. With the lambda keyword, small anonymous functions can be created. Here’s a function that returns the sum of its two arguments: lambda a, b: a+b. Lambda forms can be used wherever function objects are required. They are syntactically restricted to a single expression. Semantically, they are just syntactic sugar for a normal function definition. Like nested function definitions, lambda forms can reference variables from the containing scope
    • Note that functions created with lambda forms cannot contain statements.
  30. try
    Used to enclose code which could throw Exceptions. It must be followed by an 'except' statement.
  31. True
    The boolean true value
  32. False
    The boolean false value
  33. None
    None is frequently used to represent the absence of a value, as when default arguments are not passed to a function.
  34. strings
    The string datatype which is a sequence of characters
  35. numbers
    • 1. int - Plain integers (also just called integers) are implemented using long in C, which gives them at least 32 bits of precision
    • 2. long - Long integers have unlimited precision.
    • 3. float - Floating point numbers are usually implemented using double in C; information about the precision and internal representation of floating point numbers for the machine on which your program is running is available in sys.float_info.
    • 4. complex - Complex numbers have a real and imaginary part, which are each a floating point number.
  36. Seven Sequence Types
    • 1. String literals are written in single or double quotes: 'xyzzy', "frobozz"
    • 2. Unicode strings are much like strings, but are specified in the syntax using a preceding 'u' character: u'abc', u"def".
    • 3. Lists are constructed with square brackets, separating items with commas: [a, b, c].
    • 4. Tuples are constructed by the comma operator (not within square brackets), with or without enclosing parentheses, but an empty tuple must have the enclosing parentheses, such as a, b, c or (). A single item tuple must have a trailing comma, such as (d,).
    • 5. Bytearray objects are created with the built-in function bytearray().
    • 6. Buffer objects are not directly supported by Python syntax, but can be created by calling the built-in function buffer(). They don’t support concatenation or repetition.
    • 7. Objects of type xrange are similar to buffers in that there is no specific syntax to create them, but they are created using the xrange() function. They don’t support slicing, concatenation or repetition, and using in, not in, min() or max() on them is inefficient.
  37. \\
    Result is a single backslash
  38. \'
    Result is the ' character
  39. \"
    Result is the " character
  40. \a
    Result is the ASCII bell
  41. \b
    ACSII backspace
  42. \f
    ASCII formfeed
  43. \n
    ASCII linefeed
  44. \r
    ASCII carriage return
  45. \t
    ASCII horizontal tab
  46. \v
    ASCII vertical tab
  47. %d
    Signed decimal
  48. %i
    Signed integer decimal
  49. %o
    Signed octal value. The alternate form causes a leading zero ('0') to be inserted between left-hand padding and the formatting of the number if the leading character of the result is not already a zero.
  50. %u
    Obsolete type now... identical to %d
  51. %x
    Signed hexadecimal (lowercase)
  52. %X
    Signed hexadecimal (uppercase)
  53. %e
    Floating point exponential format (lowercase)
  54. %E
    Floating point exponential format (uppercase)
  55. %f
    Floating point decimal format
  56. %F
    Floating point decimal format
  57. %g
    Floating point format. Uses lowercase format if exponent is less than -4 or not less than precision. Decimal format otherwise
  58. %G
    Floating point format. Uses uppercase format if exponent is less than -4 or not less than precision. Decimal format otherwise
  59. %c
    Single character. Accepts integer or single character string
  60. %r
    String - converts any Python object using repr()
  61. %s
    String - converts any Python object using str()
  62. %%
    Results in the % character... no argument is converted
  63. +
    addition operator
  64. -
    subtraction operator
  65. *
    multiplication operator
  66. **
    The power operator. a ** b will give a to the power b
  67. /
    The division operator
  68. //
    Floor division. 9 //2 is 4
  69. %
    Modulus operator - Returns the remainder from a division
  70. <
    Less than
  71. >
    Greater than
  72. <=
    Less than equal to
  73. >=
    Greater than equal to
  74. ==
  75. !=
    Not equal to
  76. <>
    Not equal to
  77. ( )
    Parenthesis for defining a tuple
  78. [ ]
    Used for defining lists
  79. { }
    It is best to think of a dictionary as an unordered set of key: value pairs, with the requirement that the keys are unique (within one dictionary). A pair of braces creates an empty dictionary: {}. Placing a comma-separated list of key:value pairs within the braces adds initial key:value pairs to the dictionary; this is also the way dictionaries are written on output.
  80. @
    • Keyword for decorators
    • A decorator is any callable Python object that is used to modify a function, method or class definition. A decorator is passed the original object being defined and returns a modified object, which is then bound to the name in the definition. Python decorators add functionality to functions and methods at definition time, and thus are a higher-level construct than decorator-pattern classes.
  81. ,
    Used to stay on the same line.
  82. :
    Used to delimit the key and value in dictionaries
  83. .
    Used to identify a method on a referenced object or module
  84. =
    Assignment operator
  85. ;
    Combines multiple statements into one
  86. +=
    Add and assign
  87. -=
    Subtract and assign
  88. *=
    Multiply and assign
  89. /=
    Divide and assign
  90. //=
    Floor divide and assign
  91. %=
    Return the remainder from a division and assign
  92. **=
    The power operator and assign
Card Set
List from ex 37