GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing codescracker.com — Python not Keyword
Python not KeywordIn Python, we use the "not" keyword when we want to change the boolean value of an expression that has already been evaluated. That is, the "not" keyword returns "True", if the expression evaluates to be "False", otherwise returns "False", if the expression evaluates to be "True". For example: print(not True) print(not False) The output is: False True Python not Keyword Truth TableThe truth table of the "not" keyword in Python is:
To reverse the truth value of a boolean expression, use the "not" keyword. For example, if x is True, then "not x" is False; conversely, if x is False, then "not x" is True. Python not Keyword ExampleHere is an example of the "not" keyword in Python: print("Enter the Two Number: ", end="") numOne = int(input()) numTwo = int(input()) x = numOne>numTwo if not x: print("\nThe value", numOne, "is greater than", numTwo) else: print("\nThe value", numTwo, "is greater than", numOne) print("\n\n\n@April Fool") The snapshot given below shows the sample run of the above program, with user input of 10 and 30 as the first and second numbers: The "not" keyword in the above program reversed the result or output. Advantages of the not keyword in Python
Disadvantages of the not keyword in Python
« Previous Tutorial Next Tutorial » Practice Quizzes
Test your programming and computer science knowledge with interactive MCQs and topic-based quizzes. Popular Topics
Explore the most popular programming and computer science tutorials on CodesCracker. | ||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |