Informatics Practices
Consider the following dictionary
Book = {1 : "Informatics Practices",
2 : "Computer Science ",
3 : "Information Technology"}
Jaya executes statement: 2 in Book
Assertion (A): For the above dictionary Book, the output of the statement 2 in Book is 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.
Python Dictionaries
1 Like
Answer
Both A and R are true and R is the correct explanation of A.
Explanation
The statement 2 in Book checks if the key 2 exists in the dictionary Book. Since 2 is a key in the dictionary with the value "Computer Science ", the statement returns True. The in and not in operators in Python dictionaries return True or False depending on whether the specified key exists in the dictionary or not.
Answered By
2 Likes
Related Questions
Convert 1 GB to 1 Kilobytes.
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?
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.
Evaluate the following expression:
(i) 12/3+4**2-6/3
(ii) not True or False and True