May 2017
Intermediate to advanced
280 pages
6h 2m
English
Sometimes you will be presented with a condition where there has to be some value assigned to the argument, which will be called as the default argument. Let's try to understand with real-life scenario. Most of us fill in certain forms for job application online. Now, in the form, there is a section for gender selection. In this case, programmers have inserted a default value as female. By default your sex will be set to female if you do not specifically change this value. Same is the case with the function with default arguments. Let's try to understand this with a small code example:
def info(name, age=50): print "Name", name print "age", age info("John", age=28) info("James")
Here, the info function takes ...
Read now
Unlock full access