Post

@PythonPr Answer: D (9999)
The trap: a is a string '9', not the number 9!
› '9' * 4 performs string repetition.
› Result: '9999' (four 9s, not 36!)
For beginners: string * int repeats the string. To get 36, use int(a) * b = 9 * 4. Quotes make it a string!
English

@PythonPr Answer: D) 9999
In Python, the multiplication operator (*) can be used with a string and an integer. When a string is multiplied by an integer, the string is concatenated (repeated) that many times.
a is a string with the value '9'.
b is an integer with the value 4.
English

The output is C. Error.
Why? Python is a strongly typed language. The - operator is defined for numerical subtraction, but here, a is a string ('9') and b is an integer (4). Python does not perform implicit type conversion for arithmetic operators.
Key Concepts:
· Type Error: The operation str - int is undefined, so Python raises a TypeError.
· Type Conversion: You would need explicit conversion, e.g., print(int(a) - b) for 5, or print(a + str(b)) for string concatenation ('94').
This is a fundamental check of understanding data types and operator semantics. At @Spraditech, we emphasize these core concepts because mastering the rules of a language prevents countless bugs and is essential for writing robust, predictable code.
Follow-up: What would print(a * b) output, and why? 🧠
English

@PythonPr D because ,A is string does not multiply with B , it prints how many times you enter B
English
































