Write a program to illustrate ""Required arguments"".
Answers
GeeksforGeeks
Following is a simple C++ example to demonstrate the use of default arguments. We don't have to write 3 sum functions, onl
Explanation:
Let us understand what a required function is:
Python allows the user to create user-defined function with pre-defined characteristics. One such feature is the "required function". So it ensures whether all the parameters are passed, provided the user-defined function should follow the syntax and keywords similar to pre-defined function.
def requiredArg (str1,str2):
print(str1,str2 )
#Driver code
requiredArg ("Hello","everyone")
The above is the very simple program to illustrate "Required arguments".
First the driver code is invoked, so the function requires 2 string arguments and it is passed.
Inside the function we are printing the 2 arguments.
Suppose I write the below driver code:
requiredArg("Hello")
The above line will through "missing 1 required positional argument" error because, the function has required argument, so it requires all the parameters to be passed.