The Python Data Model
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 searches
- python data frame append
- python data frame group by
- python data type definition
- python data frame column type
- python 3d model visualization
- python data visualization packages
- python data type of variable
- python data science tutorial
- export python data to csv
- python data encryption
- python data array
- python data distribution plot