Computer Science
Assertion (A): Python supports both positional and keyword arguments in functions.
Reasoning (R): Positional arguments are assigned based on their position in the function call, while keyword arguments are assigned based on the name of the parameter.
Python Functions
2 Likes
Answer
Both A and R are true, and R is the correct explanation of A.
Explanation — Python allows both positional and keyword arguments in functions. Positional arguments are passed based on their position in the function call. The first argument passed corresponds to the first parameter in the function definition, the second argument to the second parameter, and so on. While keyword arguments are passed according to the name of the parameter in the function definition.
Answered By
3 Likes
Related Questions
Write a Python program using two functions area and perimeter to compute the area and perimeter of a rectangle. The program should take length and breadth of the rectangle as input from the user.
State whether the following statement is True or False:
The
finallyblock in Python is executed only if no exception occurs in the try block.