
CAUTION
Some files are private or not ready yet, if a link gives you a 404 that's why :)
This is a work in progress, new notes will be added daily
List of note Indexes
๐ PROJECTS๐ ART๐ TECHNOLOGY๐ SCIENCE๐ PHILO-PSYCHO๐ HISTORY๐ HEALTH๐ GAMING๐ KNOWLEDGE
.... |\| .|||. |\/| .|\\. .|.
.\\||/|. .\|..|| .\|..|||...||.....
.| .....||.|\\\\\\ ... |\\\/. .\\. .||
.\\| .|\\|..|\\ .\\\\ .\\|. .\\\\\| |\| |\\|
|\\ |\\|.. /\\\. |\|\\ \\\\|. .|\\. .\\\\|
.\\. |\\\\\\\|.. .\\| .\\||\\/|. |\\| .|/\|
\. .\\\||/\|.... \\| |\/ |\\\ |\\\| .\\| \\| ....
|\/ |\\| |\\\\\\\| |\|.\\\ \\\\. |\\\\| |\\ \\. ||..
..|||\| .. .\\\\. |\\\\\\ .\\|....|\\\. |\\\\\\ |/. |/
\\\|.. .\\\ |\\. .\\\| \\| |||\\\. ...|\\/||. .\\\
|\| |\/. /\\\\\| .\\\\. \\. .../|. .|\\\|. |\\\| |\\
. |||\\|. ..||| .\\|. |\| \\|..../\\| |\\| .\\\\\ ..
\\| .||\|.|.. |\\\|./\ \\||\. ||... .\\\\/. |\/||
..|/||. |\\\\\|. .|/\| ||. .||\\\ .|||. |\
.\/| \\\. .|\\\|||\\\||.. .|\\\\\\\|\\\\. /\\\\||. |
.|| |\\\\| .......|\\\\\\. .\\\. ..|||.... .\\\\|.. ...
\\||....|\\\\\\\\||\\\\\\\/ |\|....|||\\\\\\\/....|\\\|
||.|\||\\| .....|\\\\..\\| .|\\\. ||........ .|\|...
. |\ /\\/\\\\\\. |\. .\\\\\\. ./\\\\/ |\\\||.
.|\.|\| .|\|... .. ./\\|..|\\| ..
.|\\| .\\\\.\\\\\\\ \||...\\\|..|\\\|.||
|\. ..||....|| ... ..||\\\. .|.
... .......
โ Python | Python Variables
Python - Booleans
TrueFalse
my_list = [1, 2]
if my_list
# is the same as:
if bool(my_list)
Casting
bool(1) # True
bool(-1) # True
bool(1j) # True
bool(0) # False
bool(0.0) # False
bool(0j) # False
bool('True') # True
bool('False') # True
bool(' ') # True
bool('') # False
bool([1, 2]) # True
bool([]) # False
bool({}) # False
bool(None) # False
Logic
see: Control Flow
nice_weather = False
have_umbrella = True
if not have_umbrella or nice_weather:
# if (not have_umbrella) or nice_weather:
print('stay inside')
else:
print('go outside') # executed
The above code prints go outside because not have_umbrella evaluates first (python reads booleans from left to right), and it seems working but if we flip the variables we get:
nice_weather = True
have_umbrella = False
if not have_umbrella or nice_weather:
print('stay inside') # executed
else:
print('go outside')
The code now prints stay inside which is wrong since nice_weather = True, to fix it we could do:
nice_weather = True
have_umbrella = False
if not (have_umbrella or nice_weather):
print('stay inside')
else:
print('go outside') # executed
or using and:
nice_weather = True
have_umbrella = False
if not have_umbrella and not nice_weather:
# if (not have_umbrella) and (not nice_weather):
print('stay inside')
else:
print('go outside') # executed
but the most readable way would be to flip the statements:
nice_weather = True
have_umbrella = False
if have_umbrella or nice_weather:
print('go outside') # executed
else:
print('stay inside')