Updated Doing Nothing with Qiskit In this notebook, we demonstrate how…
페이지 정보
작성자 bryanai 작성일 25-01-28 17:24 조회 83 댓글 0본문
https://github.com/qiskit-community/qiskit-community-tutorials/blob/master/hello_world/hello_zero.ipynb
Updated Doing Nothing with Qiskit
In this notebook, we demonstrate how to create and execute a quantum circuit using Qiskit. This updated code works with the latest version of Qiskit, addressing previous issues with deprecated functions and imports.
Importing Necessary Libraries
First, we need to import the required libraries:
import qiskit
import qiskit_aer
Creating Quantum and Classical Registers
We create a quantum register with 1 qubit and a classical register with 1 bit to store measurement results:
qr = qiskit.QuantumRegister(1)
cr = qiskit.ClassicalRegister(1)
program = qiskit.QuantumCircuit(qr, cr)
Defining the Quantum Circuit
Next, we define the quantum circuit and add a measurement operation:
program.measure(qr, cr)
<qiskit.circuit.instructionset.InstructionSet at 0x1f13fe2f100>
Selecting the Backend and Transpiling the Circuit
We choose the qasm_simulator backend from Aer for simulation. The circuit is then transpiled to be compatible with this backend:
backend = qiskit_aer.Aer.get_backend('qasm_simulator')
program_ = qiskit.transpile(program, backend)
job = backend.run(program_)
Running the Circuit and Retrieving Results
Finally, we run the transpiled circuit on the simulator and print the results:
result = job.result()
counts = result.get_counts()
print(counts)
{'0': 1024}
Great! Now you are ready to create and execute programs!
관련링크
- 이전글 양자컴퓨터, 비트코인 해킹 가능하다 | 비트코인 전자서명과 SHA-256 해킹 | 논리 큐비트 1,500~3,000개면 가능? | 양자오류정정 QEC | 쇼어, 그로버 알고리즘 , 양자 컴퓨터가 뭔데????♂️ 모든 암호?
- 다음글 Welcome to the Qiskit community tutorials! In this repository, we've put together a collection of awesome community-contributed Jupyter notebooks that leverage the features of Qiskit in education and applications. Feel free to navigate this repository, t
댓글목록 0
등록된 댓글이 없습니다.