Outputs True if operand is false. It complements the operand.
Suppose we take x=10, if we will write x>20 which is originally False, but the output will be True.
x = 13 print(x>20) print(not x>20)
x = 5 y = 6 print(x>y) print(not x>y)
Write a programme to allow a person to musical show if a person is teenager or adult, and magic show if he is a teenager or kid and a horror show if he is a adult.
# a person can be either kid or teenager or adult
isKid = True
isTeenager = False
isAdult = False
if( not isKid) :
print("Person can enter Musical show")
if( not isAdult) :
print("Person can enter Magic show")
if (isAdult) :
print ("Person can enter Horror show")
A teacher is free if they are talking, they are not busy, and they are not teaching. Given these three characteristics in the boolean variables talking, not_busy, and not_teaching, print True if the teacher is free, and False otherwise.
talking = False busy = True not_teaching = True print(talking and not busy and not teaching)
'not' with numbers :
You can use the not operator to produce True if a number is zero, and False otherwise.
score = 0 print(not score)