Informatics Practices
Assertion (A): sort() method sorts the objects of list in ascending order.
Reasoning (R): Defining sort() method with reverse=True as an argument sorts the list elements in descending order.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Python List Manipulation
4 Likes
Answer
Both A and R are true and R is the correct explanation of A.
Explanation
The sort() function sorts the items of the list, by default in ascending/increasing order. If we want to sort the list in decreasing order, we need to write: sort(reverse = True).
Answered By
3 Likes
Related Questions
Assertion (A): In Python, list is an immutable collection of data.
Reasoning (R): Mutable means that any change or alteration in data is mentioned in the same place. The updated collection will use the same address for its storage.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Assertion (A): The position of each element in the list is considered as its index.
Reasoning (R): Indexing in a list can be positive and negative; index is defined using [] brackets.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Assertion (A): An empty list can be created using list() method.
Reasoning (R): The following snippet—
>>>L1 = list() >>>print(L1)will give the output as:
[]
This statement holds true.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Assertion (A): List is mutable data type.
Reasoning (R): In-place change is not possible in list elements.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.