New Question, Easy!
Q) Why does bool(23%2) returns True?
Programming Language: Python
_
#BeBrainly
Answers
Answered by
3
Answer:
- bool(23%2) returns true. The Python bool() function converts a value to boolean type.
- 23%2 returns the remainder obtained when 23 is divided by 2. 23 divided by 2 leaves reminder 1.
- bool() returns false if the value entered in the parameter are - 0, False, None, empty sequence, empty mapping and so on.
- It returns true if the value entered are other than the values written above.
- So, bool(23%2) returns True.
Attachments:
Answered by
4
Explanation:
Given,
bool(23 % 2)
> bool(1)
> True
- Because boolean values are kind of like binary data they can only store "On" or "Off", "Yes" or "No" types of data/values.
- Also in the Binary system 1 means "On" and 0 means "Off".
- So, it means all other values except 0 are evaluated as True.
Attachments:
Similar questions