Python-Quizzes | Python String Quiz | Question 16

Question 16: What is the output of the following program?

filter_none

edit
close

play_arrow

link
brightness_4
code

a = "GeeksforGeeks "
  
b = 13
  
print (a + b) 

chevron_right


(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

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.