What is the expected output of the following code if the user enters 2 and 4?
What is the expected output of the following code if the user enters 2 and 4?
x = input()
y = input()
print(x + y)
A . 4
B. 6
C. 24
D. 2
Answer: C
Explanation:
Topics: input() plus operator string concatenation
Try it yourself:
# x = input()
# y = input()
x, y = ‘2’, ‘4’ # Just for convenience
print(x + y) # 24
As always the input() function return a string.
Therefore string concatenation takes place and the result is the string 24
Latest PCEP-30-02 Dumps Valid Version with 124 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund
Subscribe
Login
0 Comments
Inline Feedbacks
View all comments