Python Programming: Lesson 44 - Default and Positional Arguments to a Function

Veröffentlicht am: 06 September 2021
auf dem Kanal: youmils03
45
0

PLEASE SUBSCRIBE!!!

In the previous lesson (   • Python Programming: Lesson 43 - Group...  ), we talked about groups in regular expressions. Here, we continue talking about groups but then bring up the concept of default arguments to a function. It turns out that inputs can have default values, and there can also be arbitrarily many inputs being passed into a function.

def f( x = 4 , y = 9 ):
return y - x

print( f() ) # 5

Above is an example of a function that has 2 default arguments. You can specify them, but they'll take default values if you don't. We can also think about positional arguments, which are treated as a tuple of arguments coming in.

def g( h , *x ):
print( h + int( x[0] ) )

g( 10 , True , True , 3.3 , "potato" ) # 11

0:23 Review of print(x, y, ...)
0:49 Review of Regular Expressions and Groups
10:23 Review of Theory of Functions
11:13 NEW: Default Function Arguments
14:41 Positional Arguments
17:38 PEEK: Keyword Arguments (next video    • Python Programming: Lesson 45 - Named...  )

Ready for more information on groups and keyword arguments? A final video on regular expressions / functions is available here:    • Python Programming: Lesson 45 - Named...  

Thanks for watching, and PLEASE SUBSCRIBE!!!


Auf dieser Seite können Sie das Online-Video Python Programming: Lesson 44 - Default and Positional Arguments to a Function mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer youmils03 06 September 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 45 Mal angesehen und es wurde von 0 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!