×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Python
Posted by: tausif alam
Added: Apr 2, 2016 11:44 AM
Views: 17
Examples of posistional and non positional argument
  1. def fn (a, b, c = 1):
  2.     return a * b + c
  3.  
  4. print fn (1, 2)                # returns 3, positional and default.
  5. print fn (1, 2, 3)             # returns 5, positional.
  6. print fn (c = 5, b = 2, a = 2) # returns 9, named.
  7. print fn (b = 2, a = 2)        # returns 5, named and default.
  8. print fn (5, c = 2, b = 1)     # returns 7, positional and named.
  9. print fn (8, b = 0)            # returns 1, positional, named and default.