GoConqr has a new look! Let us know what you think.

Mind map

Python Functions

Sachin Mishra English

Map content

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")

Information

Description
Mind Map on Python Functions, created by Sachin Mishra on 24/04/2020.
Created by
Sachin Mishra
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?