0
What is the function of true and false in python . I'm unable to understand it.
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()
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