Informatics Practices
Consider the given two statements:
T1 = [3, 9, 0, 1, 7]
T2 = [5, 1, 0, 7, 5.5]
Assertion (A): Output of print(len(T1) == len(T2)) is True.
Reasoning (R): The len() function returns the number of elements in the list. If two lists have same number of elements, then == operator will return 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.
Python List Manipulation
1 Like
Answer
Both A and R are true and R is the correct explanation of A.
Explanation
The output of print(len(T1) == len(T2)) is True because both T1 and T2 have the same number of elements (5 elements each). The len() function returns the length of the list, i.e., the number of elements in a list.
Answered By
3 Likes
Related Questions
What will be the output of the following operation?
L1 = [1,2] L2 = [3, 4] (L1 + L2)*2- [2, 4, 6, 8]
- [1, 2, 3, 4, 1, 2, 3, 4]
- [1, 3, 4, 4]
- [3, 4, 1, 2]
Assertion (A): List in Python is a collection of values of any type.
Reasoning (R): In lists, you can change the elements of a list in place.
- 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 traversal in Python is done through slicing and using for loop also.
Reasoning (R): Traversal can be done only through forward indexing.
- 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): 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.