Python 3.4 - Default Values for Arguments
Functions do things. Functions are made of arguments: "In mathematics, an argument of a function is a specific input in the function, also known as an independent variable. https://en.wikipedia.org/wiki/Argument_of_a_function
If I made a function called amount_of_hits_per_boxer I would need to arguments (name, hits)
The function would look something like this:
The output would be Tyson = 34. By giving hits a default value of zero, if there is no input for hits, no 34, than we would just get a return of Tyson = 0. If you don't give arguments default values it can mess up our program, simply stated.
https://www.protechtraining.com/content/python_fundamentals_tutorial-functions
https://www.youtube.com/watch?v=mwr1AtpLMpI
If I made a function called amount_of_hits_per_boxer I would need to arguments (name, hits)
The function would look something like this:
def amounts_of_hits_per_boxer(name, hits= 0): print(name, hits) amounts_of_hits_per_boxer('Tyson =', 34)
The output would be Tyson = 34. By giving hits a default value of zero, if there is no input for hits, no 34, than we would just get a return of Tyson = 0. If you don't give arguments default values it can mess up our program, simply stated.
https://www.protechtraining.com/content/python_fundamentals_tutorial-functions
def get_gender(sex= 'Unknown'): if sex is 'm': sex = 'Male' elif sex is 'f': sex = 'Female' print(sex) get_gender('m') get_gender('f') get_gender()
https://www.youtube.com/watch?v=mwr1AtpLMpI
Comments