The Python Data Model - University of Washington
ThePythonDataModel
UWCSE190p Summer2012
>>> conjugations = { "see":["saw", "sees"], "walk":["walked", "walks"] "do":["did", "does"] "be":["was", "is"] } >>> conjugations["see"] ??? >>> conjugations["walk"][1] ??? >>> conjugations["walk"][1][0] ??? >>> [word[0] for word in conjugations["be"]] ??? >>> [pair for pair in conjugations.items()][0] ??? >>> [(pair[0][0], pair[1][0][0]) for pair in conjugations.items()][1] ??? >>> {pair[0]:pair[1] for pair in conjugations.items()} ???
>>> def double(x): ... print "double:", x + x ... >>> print double(2) ???
Types:somedefini5onsandcontext
? Somehistoricallanguageswereuntyped
? Youcould,say,divideastringbyanumber,andtheprogramwouldconAnue. ? TheresultwassAllnonsense,ofcourse,andprogrambehaviorwascompletely
undefined. ? Thiswasconsideredunacceptable
? Modernlanguagesmaybesta+clytypedordynamicallytyped
? "staAclytyped"meansthattypesareassignedbeforetheprogramisexecuted ? "dynamicallytyped"meansthattypesareassigned(andtypeerrorscaught)at
runAme
? Modernlanguagesmaybestronglytypedorweaklytyped
? Forourpurposes,"weaklytyped"meansthelanguagesupportsasignificant numberofimplicittypeconversions.
? Forexample,(5+"3")couldtriggeraconversionfrom"3"to3
? Forourpurposes,Pythoncanbeconsidered
? stronglytyped ? dynamicallytyped
GuesstheTypes
def mbar_to_mmHg(pressure): return pressure * 0.75006
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
Related searches
- university of washington hr jobs
- university of washington jobs listing
- university of washington human resources
- university of washington human resources dept
- university of washington baseball roster
- university of washington product management
- university of washington online mba
- university of washington printable map
- university of washington opioid taper
- university of washington opioid calculator
- university of washington program management
- university of washington graduate programs