R

Ram Sharma • 3.40K Points
Extraordinary

Q. What will this code output?

Code:
def add(a, b):
return a + b

print(add('3', '4'))
  • (A) 7
  • (B) 34
  • (C) Error
  • (D) '3' + '4'
  • Correct Answer - Option(B)
  • Views: 2
  • Filed under category Python
  • Hashtags:

Explanation by: Ram Sharma
The `+` operator concatenates strings in Python, so '3' + '4' becomes '34'.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.