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
22
7
130
36.5K
하오리 🦆📒
하오리 🦆📒@haori_notes·
@PythonPr The correct answer is D. "". In Python, the * operator is used to repeat strings. So "python" * 0 means repeating "python" zero times, and since nothing gets repeated, the result is simply an empty string "".
English
0
0
11
1.5K
🅾🅼🅰🅼🅾🆁🅸
🅾🅼🅰🅼🅾🆁🅸@oMaMoriTTV·
Here are some hints, guys :)😁 First, a quick refresher on two basics in Python. A "string" is a sequence of characters used to represent text. An "integer" is a whole number without any decimal part, used for counting or math. Now let’s look at the choices🧐 A. Error → This would mean Python can’t multiply a string by zero. B. "0" → Multiplying a string by an integer repeats the string, it never returns a number. C. "Python" → This would mean multiplying by zero leaves the string unchanged. D. "" → This represents an empty string. With those hints in mind, you can now figure out which option matches the result of "Python" * 0 😚
GIF
English
0
1
8
2.5K
Tanmay Newatia
Tanmay Newatia@thetanmaydoes·
@PythonPr D: "" this was a good one, I got confused, as I know the string concatenation takes place in case of multiplication with a number, but with 0, that was a tweak. but the same occurs, hence the answer.
English
0
0
2
376
Código Pitón
Código Pitón@codigopiton·
@PythonPr Realmente, ninguna de las soluciones es válida. Cualquier cadena multiplicada por cero genera una cadena vacía, que no tiene representación. Por tanto el print, lo único que hará será imprimir un salto de línea. (No es la D, porque hacer el print no generará "").
Español
1
0
0
1K
xReaverenDx
xReaverenDx@RevMathiasLust·
@PythonPr B.) 0 or D.) "" I think.... I'm still new to this 🥰
English
0
0
0
1.7K
Paylaş