Informatics Practices
For a given list
L = [1, 2, 3, 4, 5, 6]
the index of element 4 will be:
Assertion (A): The index of element 4 will be 3 or -3.
Reasoning (R): Python list supports forward and backward indexing with -1 to given to left most and 0 to right most element.
- 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
3 Likes
Answer
A is true but R is false.
Explanation
The index of element 4 in the list L = [1, 2, 3, 4, 5, 6] is 3. Additionally, the index -3 refers to the element 4 when counting from the end of the list. Python lists support both forward (positive) and backward (negative) indexing with -1 referring to the rightmost element and 0 referring to the leftmost element.
Answered By
1 Like
Related Questions
Shikha has written the following SQL statement:
Select Name, Dept, Salary*12 as "Annual Salary" from EMP;What is "Annual Salary" in the above statement?
Consider the following dictionary
Book = {1 : "Informatics Practices", 2 : "Computer Science ", 3 : "Information Technology"}Jaya executes statement:
2 in BookAssertion (A): For the above dictionary Book, the output of the statement
2 in Bookis True.Reasoning (R): For Dictionary, the ‘in’ and ‘not in’ operators return True or False.
- 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.
Evaluate the following expression:
(i) 12/3+4**2-6/3
(ii) not True or False and True
What will be the output of the following code?
for k in range(-10, 0, 2): print(k)