Which one of the following statements is correct regarding binary operations in Python?
Explanation
Binary operations in Python can be performed over operands of different data types in Python as long as types are compatible. For example,
a = 1 + 3.14 is fine, but
a = 1 + “Hello, world” will throw a TypeError. In case when operands have different data types, more narrow one will be automatically converted to a wider data type. In previous example integer 1 will be converted to its float representation and added to 3.14 providing a float result.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Python quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes