Question:

Identify the statement from the following which will raise an error:

Show Hint

Always ensure that the operands in concatenation operations are of the same data type. Use str() to convert integers to strings if needed.

Updated On: Jan 21, 2025
  • print("A"*3)
     

  • print(5*3)
     

  • print("15" + 3)
     

  • print("15" + "13") 
     

Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

In Python:
  • Option (a): "A"*3 repeats the string "A" three times, resulting in "AAA".
  • Option (b): 5*3 performs integer multiplication, resulting in 15.
  • Option (d): "15" + "13" concatenates two strings, resulting in "1513".
  • Option (c): "15" + 3 raises a TypeError because Python does not allow concatenation of a string ("15") and an integer (3).
Was this answer helpful?
0
0