Operator and Expression

If True is of int type then how the type(True) is resulting true.
Also can we consider True equivalent to integer 1 and on the same basis false will be 0.

I am not able to track my previous doubts in the doubt section. Please ook into this… as I need to view to the response on the provious doubts

Hi @Akshay986,

True is close to an integer in Python but it’s actually a boolean and type(True) gives:
<class ‘bool’>
Also, isinstance(True, bool) gives True apart from isinstance(True, int) (This happens because of Inheritance).
But the important part that True behaves like an integer. You can use it in arithematic operations and it will behave exactly like a 1. Similarly, False also behaves like a 0.
This is happens because of some smart typecasting from Python.

Regarding your previous doubts, try accessing them through the activity panel at http://discuss.codingblocks.com/

Hope this helps!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.