What is the function of true and false in python . I'm unable to understand it. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the function of true and false in python . I'm unable to understand it.

8th Sep 2018, 12:43 PM
Aryav Shenoy
Aryav Shenoy - avatar
2 Answers
+ 2
True and False are boolean values. True = 1 False = 0 If you evaluate conditions, a bool value is returned. For example 5>4 is true. You can also use them for variables, e.g is_valid = True if (is_valid): #do something when valid/true Usually they are set by other functions, it always depends on the context. e g. is_valid = check_input()
8th Sep 2018, 12:55 PM
Matthias
Matthias - avatar
0
''' Enter an integer to test. ''' age=int(input()) if age <= 20: print(f'You are not old enough to drink.') else: print(f'You are old enough to drink') Math Operators will perform Boolean functions, here is a basic example. If something is True do a function. Of something is False do a function
8th Sep 2018, 1:12 PM
Steven M
Steven M - avatar