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’, ...
Voir