Computer Science
Assertion (A): There is no difference between a list and a tuple in Python.
Reasoning (R): The list elements are enclosed within square brackets [] separated by commas and the tuple elements are enclosed within parentheses () separated by commas.
- 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.
Answer
A is false but R is true.
Explanation
Lists are mutable, meaning their elements can be changed after creation, and they are enclosed within square brackets [] separated by commas. On the other hand, tuples are immutable, so their elements cannot be changed after creation, and they are enclosed within parentheses () separated by commas. Hence, list and tuples are not same.
Related Questions
Assertion (A): Indexing refers to accessing elements of a sequence. Python offers two types of indexing, viz. positive or forward and negative or backward indexing.
Reasoning (R): Both forward and backward indexing are implemented in all the sequences, which start with first (1st) index.
- 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): Dictionaries in Python are mutable.
Reasoning (R): The data inside a dictionary is stored as the key:value pairs enclosed within the curly braces {}.
- 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): Both max() and min() functions are implemented on lists as well as tuples in Python.
Reasoning (R): The max() and min() functions return the highest and the lowest among a set of values stored in a list or tuple respectively.
- 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): You can add an element in a dictionary using key:value pair.
Reasoning (R): A new (key:value) pair is added only when the same key doesn't exist in the dictionary. If the key is already present, then the existing key gets updated and the new entry will be made in the dictionary.
- 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.