262,061 views
38 votes
38 votes
If the following code is executed, what is the output? a = 1 b = 2. c = '3' d = (1, 2., '3') e = [4, 5., '6'] print type(b+c)

User Petr Rastegaev
by
2.7k points

1 Answer

20 votes
20 votes

Answer:

TypeError

Step-by-step explanation:

b = 2

c = '3'

- b is of type integer because it is storing an Integer.

- c is of type string, since '3' is a string.

Since they are of different types, you can't add/ concatenate them. To add them you would need to change the string ('3') to an integer to get 5. Or you would need to convert 3 into a string to get '32' or '23'.

User Kristie
by
3.1k points