Does a function always have to have parameters?


#1

Question

For this exercise, the function syntax shows parameters for the function. Is a function always required to have parameters?

Answer

NO. A function is not required to have parameters if they are not needed to perform the task done by the function code. Most functions that are found in the various Python libraries do have some type of parameters and methods for a class all have self (or equivalent name) for the first parameter even if no other parameters are required.