Q. What would Python return when following expressions are evaluated? As earlier, first evaluate these expressions on paper and then verify by writing them in Python shell.
Given:
a = "hello"
b = 15
c = 20
d = "12"
Expression | Your Result | Result in Python Shell | |
---|---|---|---|
1. | str(b) + str(c) + d + a | ||
2. | d + 10 | ||
3. | d * 3 | ||
4. | a + int(d) |
Answer :-
Expression | Your Result | Result in Python Shell | |
---|---|---|---|
1. | str(b) + str(c) + d + a | 152012hello | '152012hello' |
2. | d + 10 | Error | Error because integer and string cannot add in python |
3. | d * 3 | 121212 | '121212' |
4. | a + int(d) | Error | Error because integer and string cannot add in python |
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )