Python language: Functions, modules and objects (session 9)
38 pages
English

Python language: Functions, modules and objects (session 9)

-

Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
38 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

Python language: Functions,modules and objectsThe FOSSEE GroupDepartment of Aerospace EngineeringIIT Bombay1 May, 2010Day 2, Session 3FOSSEE Team (IIT Bombay) Basic Python 1 / 37Outline1 FunctionsDefault argumentsKeywordBuilt-in functionsExercises2 Modules3 ObjectsFOSSEE Team (IIT Bombay) Basic Python 2 / 37FunctionsOutline1 FunctionsDefault argumentsKeywordBuilt-in functionsExercises2 Modules3 ObjectsFOSSEE Team (IIT Bombay) Basic Python 3 / 37Functions Default argumentsOutline1 FunctionsDefault argumentsKeywordBuilt-in functionsExercises2 Modules3 ObjectsFOSSEE Team (IIT Bombay) Basic Python 4 / 37Functions Default argumentsFunctions: default argumentsIn []: greet = ’hello world’In []: greet.split()Out[]: [’hello’, ’world’]In []: line = ’Rossum, Guido, 54, 46, 55’In []: line.split(’,’)Out[]: [’Rossum’, ’ Guido’, ’ 54’,’ 46’, ’ 55’]FOSSEE Team (IIT Bombay) Basic Python 5 / 37Functions Default argumentsFunctions: default arguments . . .In []: def welcome(greet, name="World"):.... print greet, nameIn []: welcome("Hello")Hello WorldIn []: welcome("Hi", "Guido")Hi GuidoFOSSEE Team (IIT Bombay) Basic Python 6 / 37Functions Keyword argumentsOutline1 FunctionsDefault argumentsKeywordBuilt-in functionsExercises2 Modules3 ObjectsFOSSEE Team (IIT Bombay) Basic Python 7 / 37Functions Keyword argumentsFunctions: Keyword argumentsWe have seen the followinglegend([’sin(2y)’], loc = ’center’)plot(y, sin(y), ’g’, ...

Sujets

Informations

Publié par
Publié le 27 juin 2011
Nombre de lectures 196
Langue English

Extrait

OFSSEEeT
Python language: Functions, modules and objects
maI(TIoBbmya)
The FOSSEE Group
Department of Aerospace Engineering IIT Bombay
1 May, 2010 Day 2, Session 3
BasicPython1/37
Outline
1
2
3
OF
Functions Default arguments Keyword arguments Built-in functions Exercises
Modules
Objects
SSEETeam(IITBombay)aBsicyPhtno2/73
3
Objects
nutcFuOltoisnenieaETSEOSF
1
Functions Default arguments Keyword arguments Built-in functions Exercises
2
Modules
/37hon3cPytaBisab)yBTmo(mII
ctunFafeDsnoimugratluentsOutlinemoBTII(maeTEESSOn4hoytcPsiBay)baF
Objects
3
3/7
1
Functions Default arguments Keyword arguments Built-in functions Exercises
Modules
2
nsiofaDeFctuntsumened:snoitgratluafumrgtaulncFutsen55
greet.split() [holle,orldw]
line =’Rossum, Guido,
54,
line.split(’,’) [msousR,’ Guido’,’ 54’, ’ 46’,55’]
In []:
In []:
In []: Out[]:
In []: Out[]:
greet =’hello world’
no/573
46,
icasthPymbBo)BaymaeTTII(OFEESS
DensioctunFuFstnemugratluafcnitno:sedafluatrguments...maeTTII(OFEESS
In []: welcome("olleH") Hello World
In []: welcome("Hi",o""idGu) Hi Guido
no/673
In []:defwelcome(greet, name="Wldor"): ....printgreet, name
asicPythBombay)B
oisnnutcF/37hon7cPytBasi
Objects
3
1
Functions Default arguments Keyword arguments Built-in functions Exercises
Modules
2
m(IIETeabay)TBomSOESFtlOueinwyeKadromugrstne
rgdaenumKes:orywstKeywordaunctionsuFcnitnogrmunestF
pie(science.values(), labels = science.keys())
annotate(’local max’, xy = (1.5, 1))
We have seen the following
plot(y, sin(y),’g’, linewidth = 2)
legend([(2y)sin], loc =retnec)
/873thonicPy)BasmbayoBTII(maeTEESSOF
an(e"=emdiuGg,"on[Iwe]:omlcSOESdiFo(mIITEae="HereeteyGuy")H73/9noh
In []: welcome("eHll"o,mes""aJ) Hello James
In []: welcome("Hi", name=G"iuod") Hi Guido
y)baomTBytcPsiBaroadgrmuoisneKwyFunctt,eemena)"dl...:irp.rgtnet,n(gre"Worame=:]edI.[nocemwflergdaoryw..tsenumcnuFstneek:snoit
ontiutsOint-ncfusnoiliuBFtcnuilenSSOFeTEEam(IITBombay)BasciyPhtno013/7
1
Functions Default arguments Keyword arguments Built-in functions Exercises
3
Objects
2
Modules
bmoBTII(cisaB)yaFOamTeEESSPython11/37
10 m
Variety of built-in functions are available abs, any, all, len, max, min pow, range, sum, type Refer here:t/hdoonctsp.:py//ht.org library/functions.html
rofeirweitcnBsnoioctnngtiunafFunsnuBtcoiniufli-t
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents