Comment your answers below! #python #programming #developer #programmer #coding #coder #softwaredeveloper #computerscience #webdev #webdeveloper #webdevelopment #pythonprogramming #pythonquiz #ai #ml #machinelearning #datascience
49
20
159
Replies
@Python_Dv 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.
4
1
50
@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
0
0
3
@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.
0
0
3
@Python_Dv p = "7" q ="2" print(int(p+q) - int(q+p)) #(7 + 2) = 72 - (2 + 7) = 27 # 72 - 27 = 45 #A) 45 72 -27
0
0
2
@Python_Dv Answer: A Concatenate p and q respectively because not are strings then subtract the results which are integers , it gives you 45.
0
0
1
@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.β
0
0
0
@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.
0
0
0
@Python_Dv Your are concatenating the strings, then subtracting after converting the concatenated strings to integers. So your result is 45
0
0
0
@Python_Dv Can anyone recommend me a website where I can solve questions like this in different programming languages?
0
0
0
@Python_Dv Step 1: String concatenation Β· p + q = "7" + "2" = "72" Β· q + p = "2" + "7" = "27" Step 2: Convert to integers Β· int(p+q) = int("72") = 72 Β· int(q+p) = int("27") = 27 Step 3: Perform subtraction Β· 72 - 27 = 45 Final Answer: ``` 45 ```
0
0
0