python_cheat_sheet_4


Python Cheat Sheet 4 - type system, control flow

Table of Contents

Python's type hierarchy

Under numbers, Python has two categories:

  • Integral
    • Integers
    • Boolean, yes these are integers (0,1)
  • Non-integral
    • Floats, which are c doubles
    • Complex
    • Decimals
    • Fractions, to better represent numbers with repeating decimals

Python's Collections type hierarchy

  • Sequences
    • Mutable
      • Lists
    • Immutable
      • Tuples
      • Strings
  • Sets
    • Mutable
      • Sets
    • Immutable
      • Frozen Sets
  • Mappings
    • Dictionaries

Python's Callables and Singletons

  • Callables
    • User defined funcitons
    • generators
    • classes
    • instance methods
    • class instances (call())
    • Std. library built-in functions (e.g.: len(), open())
    • Std. library built-in methods (e.g.: my_list.append())
  • Singletons - only one instance of these can exist.
    • None
    • NotImplemented
    • Ellipsis (...) -> Find more about this.

In [ ]: