---
title: AND (latest version)
description: API reference for qiskit.circuit.library.AND in the latest version of qiskit
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/qiskit.circuit.library.AND
---

# AND

*class* `qiskit.circuit.library.AND(num_variable_qubits, flags=None, mcx_mode='noancilla')`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/circuit/library/boolean_logic/quantum_and.py#L23-L106)

Bases: [`QuantumCircuit`](/docs/api/qiskit/qiskit.circuit.QuantumCircuit "qiskit.circuit.quantumcircuit.QuantumCircuit")

A circuit implementing the logical AND operation on a number of qubits.

For the AND operation the state $|1\rangle$ is interpreted as `True`. The result qubit is flipped, if the state of all variable qubits is `True`. In this format, the AND operation equals a multi-controlled X gate, which is controlled on all variable qubits. Using a list of flags however, qubits can be skipped or negated. Practically, the flags allow to skip controls or to apply pre- and post-X gates to the negated qubits.

The AND gate without special flags equals the multi-controlled-X gate:

![Diagram illustrating the previously described circuit.](https://eu-de.quantum.cloud.ibm.com/docs/images/api/qiskit/qiskit-circuit-library-AND-1.avif)

Using flags we can negate qubits or skip them. For instance, if we have 5 qubits and want to return `True` if the first qubit is `False` and the last two are `True` we use the flags `[-1, 0, 0, 1, 1]`.

![Diagram illustrating the previously described circuit.](https://eu-de.quantum.cloud.ibm.com/docs/images/api/qiskit/qiskit-circuit-library-AND-2.avif)

> **Deprecated since version 2.1**
>
> The class `qiskit.circuit.library.boolean_logic.quantum_and.AND` is deprecated as of Qiskit 2.1. It will be removed in Qiskit 3.0. Use qiskit.circuit.library.AndGate instead.

**Parameters**

- **num\_variable\_qubits** ([*int*](https://docs.python.org/3/library/functions.html#int)) – The qubits of which the AND is computed. The result will be written into an additional result qubit.
- **flags** ([*list*](https://docs.python.org/3/library/stdtypes.html#list)*\[*[*int*](https://docs.python.org/3/library/functions.html#int)*] | None*) – A list of +1/0/-1 marking negations or omissions of qubits.
- **mcx\_mode** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) – The mode to be used to implement the multi-controlled X gate.

## Attributes

### name

Type: [`str`](https://docs.python.org/3/library/stdtypes.html#str)

A human-readable name for the circuit.

**Example**

```python
from qiskit import QuantumCircuit

qc = QuantumCircuit(2, 2, name="my_circuit")
print(qc.name)
```

```text
my_circuit
```
