Taking a leap into quantum – Hello World with Q#

Back in December 2017, Microsoft announced a Quantum Development Kit which uses Q# (Q Sharp) as its language. It is designed to be used with Visual Studio 2017. I decided to install the development kit and have a go at the usual “Hello World” example.

The development kit is explained as being capable of developing quantum code using a quantum simulator on your device.

“The development kit contains the tools you’ll need to build your own quantum computing programs and experiments. Assuming some experience with Microsoft Visual Studio or Visual Studio Code, beginners can write their first quantum program, and experienced researchers can quickly and efficiently develop new quantum algorithms.”

Source: Microsoft

Overall I found the tutorial well laid out, with lots of good explanations and examples of how some functions are equivalent to others in C, C# and Java. If you are used to C#, then Q# will be immediately familiar as it uses semicolons and braces to indicate program structure.

With this demonstration the “Hello World” is in the form of qubit, so the output on the screen is in zeroes and ones. The example also takes you through changing the program to create superposition and entanglement.

We’ll start with the simplest program possible and build it up to demonstrate quantum superposition and quantum entanglement. We will start with a qubit in a basis state |0⟩ , perform some operations on it and then measure the result.


Init:Zero 0s=1000 1s=0
Init:One 0s=0 1s=1000

Creating Superposition


Init:Zero 0s=484 1s=516
Init:One 0s=522 1s=478

Creating Entanglement


Init:Zero 0s=499 1s=501 agree=1000
Init:One 0s=490 1s=510 agree=1000

Source: Q# Worked Example

Results from a Q# exercise

This was a good introduction and first steps into programming quantum computing using Q#. I encourage you to try this yourself to get a taste of the exciting and expanding field of quantum computing.

Max Hemingway is a chief technologist for DXC Technology in the United Kingdom. With more than 25 years of experience, he has a broad and deep range of technical knowledge and is able to translate business needs into IT-based solutions. Max has a proven track record acquired through continual client engagement and delivery of leading edge infrastructures, all of which have delivered positive results for end-clients, including IT cost reduction, expansion of service capability and increased revenues. This post first appeared in Max’s blog@Max_Hemingway


Microsoft Quantum GitHub

A-Z of Digital – Q is for Quantum Computing

Speak Your Mind


This site uses Akismet to reduce spam. Learn how your comment data is processed.