Question 16: What is the output of the following program?
a = "GeeksforGeeks " b = 13 print (a + b) |
(A) GeeksforGeeks13
(B) 13GeeksforGeeks
(C) GeeksforGeeks
(D) Error
Answer: (D)
Explanation: As you can see the variable ‘b’ is of type integer and the variable ‘a’ is of type string. Also as Python is a strongly typed language we cannot simply concatenate an integer with a string. We have to first convert the integer variable to the type string to concatenate it with a string variable. So, trying to concatenate an integer variable to a string variable, an exception of type “TypeError” is occurred.
Quiz of this Question
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.