Home  >  Article  >  Backend Development  >  What does python's & mean?

What does python's & mean?

little bottle
little bottleOriginal
2019-05-22 10:17:1654534browse

Various operators are often used in python code. Here I will introduce to you the & in Python. Do you want to know what it means? Then let’s find out with the editor.

What does python's & mean?

& is a bitwise operator - AND, similar to | (or), ! (not).

Integers are represented by binary bits in computers. Programming languages ​​provide some operators that can directly operate the bits in integers, which are called bit operations.

The operands of these operators must be integers.

In computers, when & is used as a bit operation, 1&1=1, 1&0=0, 0&0=0;

When we usually use this rarely, we usually use To make a judgment, it is true as long as both are true. I believe you must have learned AND or NOT when you studied mathematics before. This is the same as mathematics.

PS: When you mention &, you will definitely mention &&, && is logical AND, for example, 2 conditions, boolean a=2>3&&1>3, when judging 2>3 is false, the second condition 1>3 will not be judged, and a=false will be directly judged. When using &, all two conditions will be judged, and then a will be assigned false, so generally when making logical judgments, && will be used, which is more efficient. !

The above is the detailed content of What does python's & mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:Can python do regression?Next article:Can python do regression?