Home > Backend Development > Python Tutorial > How to express 'and' in python

How to express 'and' in python

藏色散人
Release: 2019-08-01 15:50:04
Original
21469 people have browsed it

How to express 'and' in python

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"
Copy after login

Output:

1 - 变量 a 和 b 都为 true
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template