Python boolean expressions are widely used. First, we need to familiarize ourselves with the Python programming language. Next, let's take a look at how to use the Python Boolean expression.
- # Coding: UTF-8 # The Boolean expression has only two values: True and False.
- X = 12.4
- Y = 12.3
- Print x = y # symbol '=' is used to determine whether two numbers are equal. The result of this statement is False.
- X = 12.3
- Print x = y # The result of this statement is True.
- Print x! = Y # symbol '! = 'Is used to determine whether two numbers are not equal. The result of this statement is False.
- A = 12
- B = 14
- Print a> = B # symbol '> =' is used to determine whether a is greater than or equal to B. The result of this statement is False.
- Print a <= B # symbol '<=' is used to determine whether a is less than or equal to B. The result of this statement is True.
- Print a> B # symbol '>' is used to determine whether a is greater than B. The result of this statement is False.
- Print a <B # symbol '<' is used to determine whether a is less than B. The result of this statement is True.
- A = 'aaa'
- B = 'bbb'
- Print a> B # You can also determine the size of the two strings. The reslut of this statement is False.
- Print a <B # The result of this statement is True.
- # Note the difference between the operator "=" and operator "=". "=" is to assign the value on the right to the variable on the left.
- # "=" Is used to determine whether the value on the left is equal to the value on the right.
The above is a detailed introduction to the Python Boolean expression in the Python language. I hope you will get some benefits.