Difference between revisions of "Python:Functions"
Jump to navigation
Jump to search
Line 21: | Line 21: | ||
=Self defined functions= | =Self defined functions= | ||
− | + | Arguments are positional but can be passed by keyword too. | |
<syntaxhighlight lang='python'> | <syntaxhighlight lang='python'> |
Revision as of 20:39, 16 June 2019
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.
- int(str[,base=x)])
- Convert str to an integer. Base = 2 converts bit-string presentation ('010101').
Self defined functions
Arguments 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()