Answer: A) 45
The trick: p and q are strings, not numbers!
› p+q = "7"+"2" = "72" (concatenates)
› q+p = "2"+"7" = "27" (concatenates)
› int("72")-int("27") = 72-27 = 45
For beginners: + concatenates strings! If they were numbers, p+q=q+p and result would be 0.
@Python_Dv 45
Both p and q are defined as strings.
The plus sign with strings concatenates them. Thus
print(p+q) = 72
print(q+p) = 27
Later these output are type cast to int to perform subtraction which yields 45
@Python_Dv Answer:-(A)45
Here p and q are two strings.
Step1:- p+q means concatenate two strings
So, p+q="72" then convert it into integer. So first part become 72(int).
Step2:- q+p="27" again convert it in integer 27.
Step3:- 72-27= 45
So correct answer is 45.
@Python_Dv String concatenation disguised as arithmetic.
‘72’ − ‘27’ = 45 — the kind of trick that reminds you why context matters in both code and cognition.”
@Python_Dv p = "7" and q = "2" are strings. p + q concatenates to "72", and q + p concatenates to "27".
int(p + q) - int(q + p) converts these to integers and subtracts: int("72") - int("27") = 72 - 27 = 45.