Skip to content

Instantly share code, notes, and snippets.

@mdang
Last active January 24, 2017 15:30
Show Gist options
  • Save mdang/bc027c1973b827b126ca9bf51159c0f2 to your computer and use it in GitHub Desktop.
Save mdang/bc027c1973b827b126ca9bf51159c0f2 to your computer and use it in GitHub Desktop.
Lesson: Python Fundamentals

Python Fundamentals

Learning Objectives

Built-in Types

Falsy Values

  • None
  • False
  • Zero of any numeric type (0, 0.0)
  • Empty strings - ''
  • Empty sequences - [], ()
  • Empty mapping - {}

Boolean Operations

  • x and y
  • x or y
  • not x

Comparison Operators

Operator Meaning
< strictly less than
<= less than or equal
> strictly greater than
>= greater than or equal
== equal
!= not equal
is object identity
is not negated object identity

Numeric Types

  • int
    • 32 bits of precision
  • float
    • Numeric literals with a decimal point
  • long
    • Integers have unlimited precision
    • Suffixed with L or l, use L to avoid confusion with the number 1
  • complex
    • Suffixed with J or j

Strings

  • Enclosed in either single or double quotes
  • Can be prefaced with u for unicode strings (u'abc', u"def")
  • Splicing
  • len()

Lists

  • Enclosed in square brackets
  • [a, b, c]

Tuples

  • Optionally enclosed in parentheses
  • a, b, c or (a, b, c)
  • Empty tuples must have parentheses ()
  • A single tuple value must have a trailing comma (a,)

Dictionaries

Looping

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment