CSCI 233: Python Notes 2

scope

  • function
  • global
  • module
  • imports

    import modulename
    from modulename import identifier
    from modulename import *

common functions

  • type(x)
  • len(x)
  • isinstancetype(x, type)
  • help(x)
    help(string)

objects

  • type
  • class
  • instance
  • method

Some str methods

  • isalpha(), isdigit(), isalnum(), isspace()
    isupper(), islower()
  • upper(), lower(), capitalize(), swapcase()
  • split([sep ])
  • splitlines()
  • strip([s ]) rstrip([s ])
  • find(s [, start [, end ]])
    rfind(s [, start [, end ]])

Some list methods

  • append(x), pop(x)
  • insert(index, x), remove(x)
  • count(x)
  • reverse()

Iteration

  • while

    while expression:
        block
  • for

    for variable in sequence:
        block
  • break
  • range()