Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
64
16
215
34.6K
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr Answer: B) 55 Explanation (short & clear, tweet-ready): a and b are strings, not numbers. So a + b performs string concatenation, not addition. "5" + "5" → "55" If you want 10, convert them first: print(int(a) + int(b))
English
2
1
12
2.8K
Jenny
Jenny@JennyTheDev·
@PythonPr B. 55 Both a and b are strings (notice the quotes). So + doesn't add them — it concatenates: "5" + "5" = "55" Tip: Use int(a) + int(b) to get 10
English
0
0
7
1.9K
Sergei Kotov
Sergei Kotov@kotov_dev·
@PythonPr Answer: B) 55 The key: "5" is a STRING, not a number! › String + String = concatenation › "5" + "5" = "55" (joins them) › NOT 10 (math only works with numbers) For beginners: Quotes make it text. Want 10? Use a = 5 and b = 5 (no quotes)
English
0
0
4
2.3K
Sixtus Agbakwuru
Sixtus Agbakwuru@SixtusAgbakwuru·
@PythonPr B. 55 ✅ The quotes make "5" a string, not an integer. In Python, + between two strings performs concatenation, not addition. So "5" + "5" joins to form "55".
English
0
0
3
1.5K
Earnest Codes
Earnest Codes@Earnesto037·
@PythonPr Answer: B. 55 In Python, the variables (a) and (b) are assigned string values, not numbers, because they are enclosed in quotation marks (" "). When the (+) operator is used with strings, it performs string concatenation (joining them
English
1
0
3
346
Jay
Jay@learnaiwthme·
@PythonPr B. 55 Both a and b are strings, not numbers. So a + b performs string concatenation: "5" + "5" → "55".
English
0
0
2
928
Theo
Theo@itheo051·
@PythonPr B. 55 (Just 2 strings)
English
0
0
0
5
Mazhar Kakar
Mazhar Kakar@MazharKakar91·
@PythonPr B) 55 becouse we are doing string concatination here
English
0
0
0
1
Kevin in Vegas
Kevin in Vegas@kev_hed·
@PythonPr B. The + can be used to add numbers, or to concatenate strings, as in the example. This is an example of operator overloading.
English
0
0
0
103
ガブリエル_Gabriel🇧🇷
@PythonPr As aspas (" ") transformam o 5 em texto. Com aspas ("5"): O Python trata como uma palavra. O sinal + serve para colar uma na outra ( "5" + "5" = "55"). Reposta B.
Português
1
0
0
323
Vivek Painyuli
Vivek Painyuli@PainyuliVivek·
@PythonPr Output is 55. Because both variables are strings, the plus operator concatenates them instead of adding numerically.
English
0
0
0
13
Naim Bhuiya
Naim Bhuiya@naimbhuiya954·
@PythonPr a,b are String, so will print a string like "55".
English
0
0
0
12
Tantoba
Tantoba@Oba_Tantoba·
@PythonPr 55 The value of a and b are in string format.
English
0
0
0
60
Python Tech
Python Tech@PythonTech43716·
@PythonPr B) 55 is the right answer. a,b are the string not integer, so here we perform string concatenation.
English
0
0
0
4
Paylaş