Python:Functions: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
[[category:Python]] | [[category:Python]] | ||
=Build in function= | |||
List of all build in functions [https://docs.python.org/3/library/functions.html] | List of all build in functions [https://docs.python.org/3/library/functions.html] | ||
| Line 13: | Line 15: | ||
;input([prompt]) | ;input([prompt]) | ||
:Read and return input from standard input. Display 'prompt' first when provided. | :Read and return input from standard input. Display 'prompt' first when provided. | ||
=Self defined functions= | |||
Argument are positional but can be passed by keyword too. | |||
<syntaxhighlight lang='python'> | |||
def main(): | |||
function(par1,par2) | |||
function(par2 = <value>, par1 = <value>) | |||
return | |||
def function (par1, par2 = <defaultvalue>): | |||
codeblock | |||
return | |||
main() | |||
</syntaxhighlight> | |||
Revision as of 20:22, 11 September 2018
Build in function
List of all build in functions [1]
- len(obj1)
- Return the number of elements in obj1 (string, list, tuple, set)
- max(obj1)
- Return the largest item in obj1
- min(obj1)
Return the smallest item in obj1
- input([prompt])
- Read and return input from standard input. Display 'prompt' first when provided.
Self defined functions
Argument are positional but can be passed by keyword too.
def main():
function(par1,par2)
function(par2 = <value>, par1 = <value>)
return
def function (par1, par2 = <defaultvalue>):
codeblock
return
main()