Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
39
Task/Boolean-values/Python/boolean-values.py
Normal file
39
Task/Boolean-values/Python/boolean-values.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
>>> True
|
||||
True
|
||||
>>> not True
|
||||
False
|
||||
>>> # As numbers
|
||||
>>> False + 0
|
||||
0
|
||||
>>> True + 0
|
||||
1
|
||||
>>> False + 0j
|
||||
0j
|
||||
>>> True * 3.141
|
||||
3.141
|
||||
>>> # Numbers as booleans
|
||||
>>> not 0
|
||||
True
|
||||
>>> not not 0
|
||||
False
|
||||
>>> not 1234
|
||||
False
|
||||
>>> bool(0.0)
|
||||
False
|
||||
>>> bool(0j)
|
||||
False
|
||||
>>> bool(1+2j)
|
||||
True
|
||||
>>> # Collections as booleans
|
||||
>>> bool([])
|
||||
False
|
||||
>>> bool([None])
|
||||
True
|
||||
>>> 'I contain something' if (None,) else 'I am empty'
|
||||
'I contain something'
|
||||
>>> bool({})
|
||||
False
|
||||
>>> bool("")
|
||||
False
|
||||
>>> bool("False")
|
||||
True
|
||||
Loading…
Add table
Add a link
Reference in a new issue