How to use boolean in Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to use boolean in Python

8th Aug 2018, 8:05 PM
N C Vignesh Kumar
3 Answers
0
booleans are: True / False
8th Aug 2018, 8:07 PM
Sousou
Sousou - avatar
0
Booleans are used in situations where a comparison has a definite "yes" or "no" answer. Is 4 the square of 2? Yes. You may simply implement like so: if (4 > 2 == True): print("4>2") #comparisons return, always
8th Aug 2018, 10:54 PM
ghostwalker13
ghostwalker13 - avatar
0
some example: if True: print('Something') else: print('Nothing') Output is: Something another example: a = False b = 3 c = 5 if a == True: print(b + c) else: print(b × c) output is : 15 (due to false value of the a variable)
8th Aug 2018, 10:58 PM
Azer Xelef
Azer Xelef - avatar