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
2 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.
Assertion (A): Positional arguments in Python functions must be passed in the exact order in which they are defined in the function signature.
Reasoning (R): This is because Python functions automatically assign default values to positional arguments.
- Both A and R are true, and R is the correct explanation of A.
- Both A and R are true, and R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.