Show Menu
Cheatography

Python Bootcamp Cheat Sheet (DRAFT) by

Notes from my Python Bootcamp class running on OS X

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Jupyter shortcuts

> jupyter notebook &
command from console opens jupyter in new browser tab; & runs it in background
New -> Python3
opens a new notebook in Python3
pwd
shows current working directory
Shift+­Enter
runs code in a cell
Tab
shows methods on an object
Shift+Tab
shows help docstring
help(topic)
shows help on topic
#
comments in Python code
'''
multiline
'''
multiline comments in Python

Lexical Tokens

Operators
+, -, *, **, /, //, %, @, <<, >>, &, |, ^, ~, <, >, <=, >=, ==, !=
Delimiters
( ) [ ] { } , : . ; @ = -> += -= = /= //= %= @= &= |= ^= >>= <<= *=

Strings

len('string')
gives length of string
str(:#)
slice from [#] to end of object str, noninc­lusive
str(#:)
slice from the beginning of str to [#] noninc­lusive