GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Mindmap

Python Functions

Sachin Mishra Englisch

Inhalt der Mindmap

Python Functions

  1. Variable Function Arguments

    • Python Default Arguments
      • Any number of arguments in a function can have a default value. But once we have a default argument, all the arguments to its right must also have default values.
      • def greet(name, msg="Good morning!"): print("Hello", name + ', ' + msg) greet("Kate") greet("Bruce", "How do you do?")
    • Python Keyword Arguments
      • Python allows functions to be called using keyword arguments. When we call functions in this way, the order (position) of the arguments can be changed. Following calls to the above function are all valid and produce the same result.
      • greet(msg = "How do you do?",name = "Bruce")
    • Python Arbitrary Arguments
      • Sometimes, we do not know in advance the number of arguments that will be passed into a function. Python allows us to handle this kind of situation through function calls with an arbitrary number of arguments. In the function definition, we use an asterisk (*) before the parameter name to denote this kind of argument. Here is an example.
      • def greet(*names): print("Hello", name) greet("Monica", "Luke", "Steve", "John") greet("Monica", "Luke", "Steve", "John")

Informationen

Beschreibung
Mindmap am Python Functions, erstellt von Sachin Mishra am 24/04/2020.
Erstellt von
Sachin Mishra
Aufrufe
0
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck