microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
alex/pr-review

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

samples/python_interop/generating_n_random_bits/RunGenerateRandom.py

15lines · modecode

1import qsharp
2
3qsharp.init(project_root=".")
4
5nQubits = input("Enter the number of random bits to be generated: ")
6(results, number) = qsharp.eval(f"GenerateRandom.GenerateRandomNumbers({nQubits})")
7
8count = 0
9for result in results:
10 if result == qsharp.Result.One:
11 count += 1
12
13print(f"Bits generated: {results}")
14print(f"Number of Ones: {count}")
15print(f"The integer representation of the generated {nQubits} bits: {number}")
16