Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
16
9
57
14.2K
Sergei Kotov
Sergei Kotov@kotov_dev·
Answer: B) False The trap: None and False are both "falsy", but NOT equal! Step by step: › None is its own unique type › False is a boolean › None == False → False (different types) › bool(None) == False → True (both falsy) For beginners: None isn't False isn't 0 isn't "" isn't [] despite all these values being falsy
English
0
0
3
384
Prem Prakash
Prem Prakash@4EverPrem·
@PythonPr False False is Boolean while None checks for absence of values like null or nothing. Both are of different types, hence False.
English
0
0
2
476
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr Output: B) False None is a separate singleton object. It’s “falsy” in boolean context, but it’s not equal to False. So print(None == False) prints False
English
0
0
1
50
Paylaş