How to express AND in Python?
Python AND is expressed with "and", and the logical expression is x and y .
"and" description: Boolean "AND", if x is False, x and y return False, otherwise it returns the calculated value of y.
Python language supports logical operators. Suppose variable a is 10 and b is 20
then (a and b) returns 20.
Example:
#!/usr/bin/python # -*- coding: UTF-8 -*- a = 10 b = 20 if a and b : print "1 - 变量 a 和 b 都为 true" else: print "1 - 变量 a 和 b 有一个不为 true"
Output:
1 - 变量 a 和 b 都为 true
Related recommendations: "Python Tutorial"
The above is the detailed content of How to express 'and' in python. For more information, please follow other related articles on the PHP Chinese website!