CS 1110 Study Guide - Final Guide: Newline
Document Summary
In general, there are always 2 scopes at any given time: global scope (anything outside a function and anything w/ global, local scope (anything inside a function w/out global) Includes parameters and local variables: can"t see local scopes of other functions x = 3 def f(x); >> this x is local global y x = 2 >> this x is local too y = 3 f(x) Lists: ordered items (any), by consecutive indices from 0, want if you have a bunch of things, without care for keys. Dicts: not odered, {key:value} pairs, keys are unique, key = computing id, value = everything i know you, this can allow you to look items up by something. In lists, we can only look things up by position d d[key] = value keys() >> returns list of keys values() >> returns list of values items() >> tuple of lists. group() >> returns string if found, returns whole group if no (parentheses)