Informatics Practices
Consider the following lists:
A = [1,2]
B = [1,2]
What will be the output of the following?
print(A==B)
- True
- False
- Error
- No output
Python List Manipulation
2 Likes
Answer
True
Reason — When comparing lists A and B using the "==" operator print(A == B), Python checks if both lists have the same elements in the same order. In this case, both lists A and B contain the elements [1, 2], so the comparison A == B evaluates to True.
Answered By
2 Likes
Related Questions
Consider the following lists:
L1 = ["this", "is", "a", "list"] L2 = ["this", "is", "another list"]Which of the following statements will result in an error?
- L1 = L2
- L1.copy()
- L2.append(1, 2, 3)
- L2.pop()
Consider the following code:
>>>A = [10, 20, 30, 40] >>>B = A.copy() >>>A[2] = 50 >>>BWhich of the following will be the elements of list A and B?
- A = [10, 20, 50, 40]
B = [10, 20, 30, 40] - A = [10, 20, 30, 40]
B = [10, 20, 50, 40] - A = [10, 20, 30, 40, 50]
B = [10, 20, 50, 40] - A = [10, 20, 40]
B = [10, 20, 50, 40]
- A = [10, 20, 50, 40]
Which of the following functions will return the first occurrence of the specified element in a list?
- sort()
- value()
- index()
- Sorted()
Given A = "[22, 4.88, "India", "T"]" the data type of A is
- List
- String
- Dictionary
- Tuple