Post

@PythonPr Answer: D) 1010
String repetition, not math!
› a = "10" is a string (notice the quotes!)
› a * 2 repeats the string twice
› "10" * 2 = "1010" (not 20!)
For beginners: Strings multiply by repeating! "ha" * 3 = "hahaha". Want math? Use int("10") * 2 = 20.
English

@PythonPr Answer: (d) 1010
The code initializes the variable a as a string with the value "10". The next line assigns the value of a to the variable b. The third line reassigns a to the result of a * 2. In Python, when you multiply a string by an integer, the string is repeated
English

@PythonPr 1010
Since 10 is enclosed within quotes, it is a string and not int. The asterisk when applied to strings, it multiplies the string with the multiplicand.
English





















