Test Index

CBSE Class 12 Computer Science 2026 Paper Set 4 Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 20 of 37
Marks: +1, -0
Assertion (A) : [1,2,3]+'123' is an invalid expression in Python.
Reason (R) : In Python, a list cannot be concatenated with a string.
Solution:  
Explanation:
Assertion: the + operator joins two objects only when both are lists (or both are strings, both tuples). Here a list is added to a string, so Python raises an error:
>>> [1,2,3]+'123'
TypeError: can only concatenate list (not "str") to list
So A is true.
Reason: a list cannot be concatenated with a string. This is true, and it is exactly why the expression in A is invalid.
Both are true and R correctly explains A.
Answer:
Option A (Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation for Assertion (A).)
© examsnet.com
Advertisements
Go to Question: