CBSE Class 11 Informatics Practices Question 10 of 40

Practice Paper — Question 10

Back to all questions
10
Question

Question 10

What will be the correct output of the following code:

a, b = '30', '5'
c = a+b
print(c)
  1. 19
  2. 305
  3. ValueError
  4. TypeError
Answer

305

Reason — In the above code, a and b are strings as they are enclosed in quotes. When using the + operator with strings, it performs concatenation rather than arithmetic addition. Therefore, a + b results in the concatenation of '30' and '5', producing '305'.