Python-Ref > Basic usage > Functions > Functions with variable number of arguments
 
 

<-^^->
Klíčová slova
Moduly
Knihovní funkce

Functions with variable number of arguments

It is very common in Python, and convenient as well, to have functions that may be called with different number of arguments.
Expand/Shrink
Zdroj: (func2-1.py)
  1   x = 3.1415927
  2   
  3   print round( x)   # round the number 'x', by default to 0 decimal places
  4   print round( x, 2)    # the second argument specifies the precission
stdout:
3.0
3.14
Doba běhu: 21.1 ms
In Python documentation optional parameters are specified in square brackets.
More information about optional arguments is given in the example Creating functions with keyword arguments.