import doctest
import projectq
from projectq.ops import H, Measure
def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int:
"""
>>> isinstance(get_random_number(projectq.MainEngine()), int)
True
"""
qubit = quantum_engine.allocate_qubit()
H | qubit
Measure | qubit
return int(qubit)
if __name__ == "__main__":
doctest.testmod()
quantum_engine = projectq.MainEngine()
random_numbers_list = [get_random_number(quantum_engine) for _ in range(10)]
quantum_engine.flush()
print("Random numbers", random_numbers_list)