Sitelet https://github.com/microsoft/qdk/tree/main/samples/python_interop/generating_n_random_bits
Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Passing arguments from Python to Q# and processing measurement results in Python

In this example, a Q# program generates an array of random bits of user-defined length (nQubits). The program creates a random bit sequence by applying an $H$ gate to each of the qubits, measuring them, and returning a tuple containing the measurement results in an array along with the integer representation of the generated bits or the random number. The Python program then processes the resulting array of bits by counting the number of Ones and displays this count along with the array of random bits and the integer representation of the generated bits.