a, b = 12, 5
if a+b:
print('True')
else:
print('False')
Write output with explanation in comment
a, b = 12, 5
if a+b:
print('True')
else:
print('False')
Write output with explanation in comment
For further actions, you may consider blocking this person and/or reporting abuse
Saurabh Dashora -
Willochs Ojigbo -
Pramit Marattha -
Varshith V Hegde -
Once suspended, lakshyatyagi24 will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, lakshyatyagi24 will be able to comment and publish posts again.
Once unpublished, all posts by lakshyatyagi24 will become hidden and only accessible to themselves.
If lakshyatyagi24 is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Lakshya Tyagi.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community 👩💻👨💻 safe. Here is what you can do to flag lakshyatyagi24:
Unflagging lakshyatyagi24 will restore default visibility to their posts.
Top comments (7)
All these answers are saying
True
, and that's right, but many of them suggest if an integer is greater than zero it's True, and that's not quite right - in effect, a coercion of an integer to boolean is performingx != 0
, so negative numbers also end up as True:'True' because 12+5=17 (int) and bool(int>0) = True
Result will be 'True' because by default, all Python Boolean values greater than 0 result to True.
Via the decoupling a becames 12 and b becames 5 thus their joined sum becames 17. Since 17 is a truthy value it passed the if check and thus prints True
True
True
True as int value is 17 which is greater than 0, and in python all boolean values greater than 0 given true output.