Quantum Computing Basics With Qiskit

Quantum Computing Basics With Qiskit

Every classical computer reduces the world to 0s and 1s. That binary framework has carried us from calculators to supercomputers, but some problems demand checking through 2n possibilities, a task that outpaces even the best machines. Now, what if information could exist in many states at once? That what if turned into a new model called quantum computation. Keep reading to break with binaries and get an overview of quantum computing basics.

By the end of this tutorial, you’ll understand that:

  • Qubits, or quantum bits, are the basic units of quantum computing.
  • A qubit can be in a superposition of 0 and 1. This means its state is a precise combination of both until measurement forces it to become either 0 or 1.
  • The Bloch sphere is a standard way to visualize what a single qubit is doing.
  • Entanglement creates strong correlations between two or more qubits, so measuring one tells you something about the others that you can’t explain with classical reasoning alone.
  • Interference adjusts probability amplitudes so that wrong outcomes cancel and useful outcomes reinforce.
  • Quantum hardware comes in different architectures, each with its own strengths and limitations.
  • With Python libraries like Qiskit, you can build and run quantum circuits directly from Python.

Before you jump in, it’d be a good idea to go through the basics of classical computing. For example, knowing how bits work, what logic gates like AND and NOT do, and how you can determine the runtime complexity of an algorithm using Big O notation will help you understand the differences and advantages of quantum computing.

Take the Quiz: Test your knowledge with our interactive “Quantum Computing Basics With Qiskit” quiz. You’ll receive a score upon completion to help you track your learning progress:


Interactive Quiz

Quantum Computing Basics With Qiskit

Test your understanding of quantum computing basics, including superposition, qubits, entanglement, and key programming concepts.

Introduction to Quantum Computing

Quantum computing is the use of fundamental ideas from quantum mechanics to perform computations on special devices called quantum computers. Quantum systems can process information in ways that classical computers can’t. For example, they can explore multiple possibilities at once. This capability is thanks to concepts like superposition, entanglement, and interference, which you’ll explore soon.

To see how quantum computing works, it helps to look at the main quantum concepts in the context of computing and consider how they differ from classical approaches. You’ll cover these essential concepts in this tutorial.

Before moving on, keep in mind that quantum mechanics and quantum computing are often counterintuitive because they occur only at very small scales and not in everyday life. Even Niels Bohr, one of the founders of quantum theory, once said:

If quantum mechanics hasn’t profoundly shocked you, you haven’t understood it yet. (Source)

— Niels Bohr

Until recently, quantum computing was seen almost entirely as a physics domain, which kept people in other fields from applying it to their own work. The good news is that you don’t need to fully grasp the physics to understand how quantum computers can solve some problems more efficiently than classical ones. You can focus on the concepts and their implementation, and only later dive into the math if you want a deeper understanding.

To start, you’ll look at the basic unit of quantum information—quantum bits, or qubits—and learn how they differ from classical bits.

Qubits, Superposition, and Measurement

Qubits, or quantum bits, are the fundamental units of quantum information. A classical bit can only be 0 or 1, but a qubit can exist in a linear combination of both states at once, a property called superposition. Physically, this usually means that the qubit is a two-level system, such as two energy levels of an atom, that can exist in a superposition of those levels.

Superposition allows qubits to represent multiple possibilities at the same time, allowing quantum computing programs to explore many solutions in parallel.

To understand superposition, think of flipping a coin. A classical coin lands as either heads or tails. A quantum coin, however, can exist in a state that’s a blend of both heads and tails simultaneously. This is what physicists mean when they say a qubit exists in a linear combination of 0 and 1.

The key difference is that while the coin is spinning in the air, you know it’ll eventually be one or zero, whereas a qubit in superposition has no definite value until it is measured.

A qubit remains in superposition until you look at it, or more formally, measure it. Measurement forces the qubit to collapse into one of its basis states, 0 or 1, just like your usual classical bits. The outcome is probabilistic: You can’t know in advance which result you’ll get, but you can calculate the chances based on the qubit’s state beforehand.

Visualizing qubits and superposition is tricky and needs some extra mathematical tools. Turns out, a coin that’s free to rotate in three dimensions is a good analogy for one way of visualizing the quantum state of a qubit, called the Bloch Sphere.

The Bloch sphere is a geometrical, 3D sphere that’s often used to visualize qubits and their superpositions. The states of the qubits, including superpositions, are represented as points on the surface of a sphere. The closer the point is to the north pole, the higher the chance of measuring 0, and vice versa for 1:

A Bloch sphere showing a qubit in the states 0 and 1.
Two Bloch spheres showing a qubit in the 0 (left) state and a qubit in the 1 state (right)

For example, the north pole represents the state 0, and the south pole represents 1. What’s interesting about this sphere is that you can visualize superposition states as well:

A Bloch sphere showing a qubit in a superposition state.
A Bloch sphere showing a qubit in a superposition state.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Article

Already a member? Sign-In

Locked learning resources

The full article is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Article

Already a member? Sign-In

About Negar Vahid

Negar is a researcher in quantum computing and explainable AI, and a content creator at Real Python.

» More about Negar

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

What Do You Think?

What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment below and let us know.

Commenting Tips: The most useful comments are those written with the goal of learning from or helping out other students. Get tips for asking good questions and get answers to common questions in our support portal.


Looking for a real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!

Become a Member to join the conversation.

Keep Learning

Related Topics: intermediate data-science