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
39
13
140
12.9K
Sergei Kotov
Sergei Kotov@kotov_dev·
@PythonPr B) 1010 The key: "10" is a string, not a number! › String * integer = repetition › "10" * 2 repeats "10" twice › Result: "1010" (not 20!) For beginners: Quotes = text mode. Want 20? Use the value without quotes.
English
0
0
9
974
Siddartha DevOps
Siddartha DevOps@SiddarthaDevops·
@PythonPr a = "10", a is not a number, its a string containing the charcaters "1" and "0". b = 2. this is the integer. in python, when you multiply a string by a integer, python repeats the string that many times. "10" * 2 = 1010 #Output Answer: 1010
English
1
0
8
923
ANKIT 𓃱
ANKIT 𓃱@A9kitSingh·
@PythonPr B) 1010 "10" is a string, so a * b repeats it twice: "10" * 2 → "1010".
English
0
0
3
125
Mira
Mira@iammira_1·
@PythonPr The answer is B) because the string is repeated twice.
English
0
0
2
435
Jenny
Jenny@JennyTheDev·
@PythonPr B) 1010 "10" * 2 repeats the string, not the math. Python doesn't assume. You do.
English
0
0
2
555
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr Answer: B) 1010 Reason: a is a string ("10"), not a number. In Python, multiplying a string by an integer repeats the string.
English
0
0
1
454
Jay
Jay@learnaiwthme·
@PythonPr The correct answer is B: 1010. a is a string, not a number. In Python, multiplying a string by an integer repeats the string. a = "10" b = 2 print(a * b) This becomes: "10" * 2 → "1010" So Python concatenates "10" twice instead of doing math.
English
0
0
1
91
Prestige | web freelancing
Prestige | web freelancing@scorehigh1930·
@PythonPr Answer: B — 1010 In Python, "10" is a string. When a string is multiplied by an integer, Python repeats the string instead of doing arithmetic. So "10" * 2 results in "1010"
English
0
0
1
98
Python Tech
Python Tech@PythonTech43716·
@PythonPr B) 1010 is the right ✅️ Here a is the string not a list, so this is work like string multiplication.
English
0
0
1
65
Ehshanulla
Ehshanulla@Ehshanulla·
@PythonPr a is a string b is an integer In Python, string × integer = string repetition output= 1010
English
0
0
1
38
Asma Hakimi
Asma Hakimi@HakimiAsma25252·
@PythonPr 1010✅ In Python, when a string is multiplied by a int, that string is repeated. "10" * 2 → "10" + "10" → "1010"
English
0
0
0
47
Terrence
Terrence@terrenceeleven·
@PythonPr B. 1010 I would have gone with Error because variable "a" is a string .@PythonPr
English
0
0
0
111
Nikhil | Data Analytics
Nikhil | Data Analytics@nikku762·
@PythonPr Answer: B (1010) Because a is a string, so Python repeats it b times instead of doing multiplication.
English
0
0
0
9
Roby
Roby@RobyDread·
@PythonPr B. 1010 a = "10" <--- al llevar " " pasa a ser str b = 2 <---- int print(a * b) <----- 10str * 2 int = 1010
Română
0
0
0
9
Paylaş